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": {} } } 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 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/ 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/.stats.yml b/.stats.yml index 96825facf..438843fd3 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 -config_hash: bcf82bddb691f6be773ac6cae8c03b9a +configured_endpoints: 139 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-d6a851f21804170f796637f1911c3382f1c57f5ed6b9b77cd7d0c6f74c06e174.yml +openapi_spec_hash: 82df33badf54d0c7087a61145d379f58 +config_hash: 3279841440b02d4e8303c961d6983492 diff --git a/CHANGELOG.md b/CHANGELOG.md index 15283c170..ce082a489 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,66 @@ # Changelog +## 0.2.0 (2026-03-07) + +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 ([f8d96a9](https://github.com/orbcorp/orb-csharp/commit/f8d96a964bd732ba6c1bba0c9285cb0905f72a98)) +* **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/README.md b/README.md index 9837e0837..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. @@ -253,10 +251,143 @@ 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. +### 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. 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 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.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..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", @@ -844,4 +886,151 @@ 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"], + }, + ], + 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", + }, + }, + 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/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..cd6b958ff 100644 --- a/src/Orb.Tests/Models/Alerts/AlertCreateForSubscriptionParamsTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertCreateForSubscriptionParamsTest.cs @@ -17,14 +17,18 @@ public void FieldRoundtrip_Works() SubscriptionID = "subscription_id", Thresholds = [new(0)], Type = AlertCreateForSubscriptionParamsType.UsageExceeded, + GroupingKeys = ["string"], MetricID = "metric_id", + PricingUnitID = "pricing_unit_id", }; string expectedSubscriptionID = "subscription_id"; List expectedThresholds = [new(0)]; ApiEnum expectedType = AlertCreateForSubscriptionParamsType.UsageExceeded; + List expectedGroupingKeys = ["string"]; string expectedMetricID = "metric_id"; + string expectedPricingUnitID = "pricing_unit_id"; Assert.Equal(expectedSubscriptionID, parameters.SubscriptionID); Assert.Equal(expectedThresholds.Count, parameters.Thresholds.Count); @@ -33,7 +37,14 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedThresholds[i], parameters.Thresholds[i]); } Assert.Equal(expectedType, parameters.Type); + Assert.NotNull(parameters.GroupingKeys); + Assert.Equal(expectedGroupingKeys.Count, parameters.GroupingKeys.Count); + for (int i = 0; i < expectedGroupingKeys.Count; i++) + { + Assert.Equal(expectedGroupingKeys[i], parameters.GroupingKeys[i]); + } Assert.Equal(expectedMetricID, parameters.MetricID); + Assert.Equal(expectedPricingUnitID, parameters.PricingUnitID); } [Fact] @@ -46,8 +57,12 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Type = AlertCreateForSubscriptionParamsType.UsageExceeded, }; + Assert.Null(parameters.GroupingKeys); + Assert.False(parameters.RawBodyData.ContainsKey("grouping_keys")); Assert.Null(parameters.MetricID); Assert.False(parameters.RawBodyData.ContainsKey("metric_id")); + Assert.Null(parameters.PricingUnitID); + Assert.False(parameters.RawBodyData.ContainsKey("pricing_unit_id")); } [Fact] @@ -59,11 +74,17 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Thresholds = [new(0)], Type = AlertCreateForSubscriptionParamsType.UsageExceeded, + GroupingKeys = null, MetricID = null, + PricingUnitID = null, }; + Assert.Null(parameters.GroupingKeys); + Assert.True(parameters.RawBodyData.ContainsKey("grouping_keys")); Assert.Null(parameters.MetricID); Assert.True(parameters.RawBodyData.ContainsKey("metric_id")); + Assert.Null(parameters.PricingUnitID); + Assert.True(parameters.RawBodyData.ContainsKey("pricing_unit_id")); } [Fact] @@ -83,6 +104,24 @@ public void Url_Works() url ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new AlertCreateForSubscriptionParams + { + SubscriptionID = "subscription_id", + Thresholds = [new(0)], + Type = AlertCreateForSubscriptionParamsType.UsageExceeded, + GroupingKeys = ["string"], + MetricID = "metric_id", + PricingUnitID = "pricing_unit_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/AlertListPageResponseTest.cs b/src/Orb.Tests/Models/Alerts/AlertListPageResponseTest.cs index 08fc76f49..850b82be1 100644 --- a/src/Orb.Tests/Models/Alerts/AlertListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Alerts/AlertListPageResponseTest.cs @@ -35,6 +35,8 @@ public void FieldRoundtrip_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -61,6 +63,8 @@ public void FieldRoundtrip_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), }, ]; PaginationMetadata expectedPaginationMetadata = new() @@ -103,6 +107,8 @@ public void SerializationRoundtrip_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -143,6 +149,8 @@ public void FieldRoundtripThroughSerialization_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -176,6 +184,8 @@ public void FieldRoundtripThroughSerialization_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), }, ]; PaginationMetadata expectedPaginationMetadata = new() @@ -218,6 +228,8 @@ public void Validation_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), }, ], PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, @@ -225,4 +237,42 @@ 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 }], + GroupingKeys = ["string"], + LicenseType = new("id"), + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + AlertListPageResponse copied = new(model); + + Assert.Equal(model, 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/AlertTest.cs b/src/Orb.Tests/Models/Alerts/AlertTest.cs index 70f2dffe9..8ddc83a4c 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; @@ -32,12 +32,14 @@ public void FieldRoundtrip_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), }; 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", @@ -51,13 +53,15 @@ 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 = [ new() { InAlert = true, ThresholdValue = 0 }, ]; + List expectedGroupingKeys = ["string"]; + LicenseType expectedLicenseType = new("id"); Assert.Equal(expectedID, model.ID); Assert.Equal(expectedCreatedAt, model.CreatedAt); @@ -80,6 +84,13 @@ public void FieldRoundtrip_Works() { Assert.Equal(expectedBalanceAlertStatus[i], model.BalanceAlertStatus[i]); } + Assert.NotNull(model.GroupingKeys); + Assert.Equal(expectedGroupingKeys.Count, model.GroupingKeys.Count); + for (int i = 0; i < expectedGroupingKeys.Count; i++) + { + Assert.Equal(expectedGroupingKeys[i], model.GroupingKeys[i]); + } + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -104,6 +115,8 @@ public void SerializationRoundtrip_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -134,6 +147,8 @@ public void FieldRoundtripThroughSerialization_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -143,7 +158,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", @@ -157,13 +172,15 @@ 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 = [ new() { InAlert = true, ThresholdValue = 0 }, ]; + List expectedGroupingKeys = ["string"]; + LicenseType expectedLicenseType = new("id"); Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedCreatedAt, deserialized.CreatedAt); @@ -186,6 +203,13 @@ public void FieldRoundtripThroughSerialization_Works() { Assert.Equal(expectedBalanceAlertStatus[i], deserialized.BalanceAlertStatus[i]); } + Assert.NotNull(deserialized.GroupingKeys); + Assert.Equal(expectedGroupingKeys.Count, deserialized.GroupingKeys.Count); + for (int i = 0; i < expectedGroupingKeys.Count; i++) + { + Assert.Equal(expectedGroupingKeys[i], deserialized.GroupingKeys[i]); + } + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -210,6 +234,8 @@ public void Validation_Works() Thresholds = [new(0)], Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = [new() { InAlert = true, ThresholdValue = 0 }], + GroupingKeys = ["string"], + LicenseType = new("id"), }; model.Validate(); @@ -240,6 +266,10 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.BalanceAlertStatus); Assert.False(model.RawData.ContainsKey("balance_alert_status")); + Assert.Null(model.GroupingKeys); + Assert.False(model.RawData.ContainsKey("grouping_keys")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -291,10 +321,16 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = null, + GroupingKeys = null, + LicenseType = null, }; Assert.Null(model.BalanceAlertStatus); Assert.True(model.RawData.ContainsKey("balance_alert_status")); + Assert.Null(model.GroupingKeys); + Assert.True(model.RawData.ContainsKey("grouping_keys")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -320,10 +356,43 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Type = AlertType.CreditBalanceDepleted, BalanceAlertStatus = null, + GroupingKeys = null, + LicenseType = null, }; 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 }], + GroupingKeys = ["string"], + LicenseType = new("id"), + }; + + Alert copied = new(model); + + Assert.Equal(model, copied); + } } public class MetricTest : TestBase @@ -370,6 +439,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 +531,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 @@ -462,6 +557,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 @@ -487,6 +583,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 @@ -572,4 +669,76 @@ 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); + } +} + +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.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/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..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, @@ -250,6 +262,145 @@ 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() + { + 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 = "license_type_id", + }; + + Allocation copied = new(model); + + Assert.Equal(model, copied); + } } public class FilterTest : TestBase @@ -332,6 +483,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 06be5d09c..97a685bc0 100644 --- a/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/BetaCreatePlanVersionParamsTest.cs @@ -70,8 +70,57 @@ public void FieldRoundtrip_Works() }, ], 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, Price = new Models::NewPlanUnitPrice() { @@ -109,6 +158,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -171,8 +221,57 @@ public void FieldRoundtrip_Works() }, ], 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() { @@ -210,6 +309,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -272,8 +372,57 @@ public void FieldRoundtrip_Works() }, ], 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, Price = new Models::NewPlanUnitPrice() { @@ -311,6 +460,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -378,8 +528,57 @@ public void FieldRoundtrip_Works() }, ], 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() { @@ -417,6 +616,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -528,6 +728,319 @@ 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", + 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() + { + 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", + }, + }, + ], + 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", + 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", + }, + }, + ], + SetAsDefault = true, + }; + + BetaCreatePlanVersionParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class AddAdjustmentTest : TestBase @@ -840,6 +1353,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 @@ -1165,8 +1711,57 @@ public void FieldRoundtrip_Works() }, ], 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, Price = new Models::NewPlanUnitPrice() { @@ -1204,6 +1799,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1230,8 +1826,56 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + 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() { @@ -1268,11 +1912,13 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; Assert.Equal(expectedAllocationPrice, model.AllocationPrice); + Assert.Equal(expectedLicenseAllocationPrice, model.LicenseAllocationPrice); Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); Assert.Equal(expectedPrice, model.Price); } @@ -1303,8 +1949,57 @@ public void SerializationRoundtrip_Works() }, ], 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, Price = new Models::NewPlanUnitPrice() { @@ -1342,6 +2037,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1379,8 +2075,57 @@ public void FieldRoundtripThroughSerialization_Works() }, ], 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, Price = new Models::NewPlanUnitPrice() { @@ -1418,6 +2163,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1451,8 +2197,56 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + 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() { @@ -1489,11 +2283,13 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); + Assert.Equal(expectedLicenseAllocationPrice, deserialized.LicenseAllocationPrice); Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); Assert.Equal(expectedPrice, deserialized.Price); } @@ -1524,8 +2320,57 @@ public void Validation_Works() }, ], 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, Price = new Models::NewPlanUnitPrice() { @@ -1563,6 +2408,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1578,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); @@ -1598,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); @@ -1616,24 +2467,158 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() var model = new AddPrice { AllocationPrice = null, + LicenseAllocationPrice = null, PlanPhaseOrder = null, Price = null, }; 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", + 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() + { + 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", + }, + }; + + AddPrice copied = new(model); + + Assert.Equal(model, copied); + } } -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", @@ -1664,6 +2649,7 @@ public void NewPlanUnitValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1671,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() { @@ -1720,6 +2714,7 @@ public void NewPlanTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1727,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, @@ -1764,6 +2767,7 @@ public void NewPlanBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1773,7 +2777,7 @@ public void NewPlanBulkValidationWorks() [Fact] public void BulkWithFiltersValidationWorks() { - Price value = new BulkWithFilters() + LicenseAllocationPrice value = new BulkWithFilters() { BulkWithFiltersConfig = new() { @@ -1784,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, @@ -1815,6 +2828,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1822,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", @@ -1859,6 +2881,7 @@ public void NewPlanPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1866,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, @@ -1908,6 +2939,7 @@ public void NewPlanMatrixValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1915,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() { @@ -1960,6 +3000,7 @@ public void NewPlanThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1967,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() { @@ -2012,6 +3061,7 @@ public void NewPlanTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2019,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() { @@ -2075,6 +3133,7 @@ public void NewPlanTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2082,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", @@ -2097,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, @@ -2127,6 +3194,7 @@ public void NewPlanGroupedTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2134,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() { @@ -2190,6 +3265,7 @@ public void NewPlanTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2197,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() { @@ -2239,6 +3323,7 @@ public void NewPlanPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2246,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", @@ -2283,6 +3376,7 @@ public void NewPlanUnitWithPercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2290,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", @@ -2303,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, @@ -2333,6 +3435,7 @@ public void NewPlanMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2342,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" }] @@ -2378,6 +3490,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2385,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", @@ -2422,6 +3543,7 @@ public void NewPlanUnitWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2429,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", @@ -2441,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, @@ -2471,6 +3601,7 @@ public void NewPlanGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2478,9 +3609,9 @@ public void NewPlanGroupedAllocationValidationWorks() } [Fact] - public void NewPlanBulkWithProrationValidationWorks() + public void BulkWithProrationValidationWorks() { - Price value = new Models::NewPlanBulkWithProrationPrice() + LicenseAllocationPrice value = new BulkWithProration() { BulkWithProrationConfig = new( [ @@ -2488,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, @@ -2520,6 +3659,7 @@ public void NewPlanBulkWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2527,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", @@ -2539,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, @@ -2570,6 +3717,7 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2577,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", @@ -2589,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, @@ -2629,6 +3784,7 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2638,7 +3794,7 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() [Fact] public void GroupedWithMinMaxThresholdsValidationWorks() { - Price value = new GroupedWithMinMaxThresholds() + LicenseAllocationPrice value = new GroupedWithMinMaxThresholds() { Cadence = GroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() @@ -2649,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, @@ -2678,6 +3843,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2685,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", @@ -2704,7 +3879,6 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() }, ], }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2734,6 +3908,7 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2741,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", @@ -2757,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, @@ -2787,6 +3970,7 @@ public void NewPlanGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2794,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", @@ -2810,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, @@ -2840,6 +4032,7 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2847,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() { @@ -2869,6 +4069,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -2900,6 +4101,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2907,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() { @@ -2963,6 +4172,7 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2970,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 = @@ -2989,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, @@ -3019,6 +4237,7 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3028,7 +4247,7 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() [Fact] public void CumulativeGroupedAllocationValidationWorks() { - Price value = new CumulativeGroupedAllocation() + LicenseAllocationPrice value = new CumulativeGroupedAllocation() { Cadence = CumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() @@ -3039,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, @@ -3068,6 +4296,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3075,13 +4304,22 @@ public void CumulativeGroupedAllocationValidationWorks() } [Fact] - public void MinimumValidationWorks() + public void MinimumCompositeValidationWorks() { - Price value = new Minimum() + LicenseAllocationPrice value = new MinimumComposite() { - Cadence = MinimumCadence.Annual, + Cadence = MinimumCompositeCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3111,6 +4349,7 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3118,15 +4357,23 @@ public void MinimumValidationWorks() } [Fact] - public void NewPlanMinimumCompositeValidationWorks() + public void PercentValidationWorks() { - Price value = new Models::NewPlanMinimumCompositePrice() + LicenseAllocationPrice value = new Percent() { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3155,6 +4402,7 @@ public void NewPlanMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3162,14 +4410,28 @@ public void NewPlanMinimumCompositeValidationWorks() } [Fact] - public void PercentValidationWorks() + public void EventOutputValidationWorks() { - Price value = new Percent() + LicenseAllocationPrice value = new EventOutput() { - Cadence = PercentCadence.Annual, + 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", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3198,6 +4460,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3205,19 +4468,23 @@ public void PercentValidationWorks() } [Fact] - public void EventOutputValidationWorks() + public void UnitSerializationRoundtripWorks() { - Price value = new EventOutput() + LicenseAllocationPrice value = new Unit() { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + 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() @@ -3246,22 +4513,49 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", 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 NewPlanUnitSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Price value = new Models::NewPlanUnitPrice() + LicenseAllocationPrice value = new Tiered() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = TieredCadence.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 }, + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3290,83 +4584,36 @@ public void NewPlanUnitSerializationRoundtripWorks() 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, - }, - 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 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, @@ -3396,11 +4643,15 @@ public void NewPlanBulkSerializationRoundtripWorks() 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); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -3408,7 +4659,7 @@ public void NewPlanBulkSerializationRoundtripWorks() [Fact] public void BulkWithFiltersSerializationRoundtripWorks() { - Price value = new BulkWithFilters() + LicenseAllocationPrice value = new BulkWithFilters() { BulkWithFiltersConfig = new() { @@ -3419,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, @@ -3450,23 +4710,35 @@ public void BulkWithFiltersSerializationRoundtripWorks() 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); + 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", @@ -3497,29 +4769,41 @@ public void NewPlanPackageSerializationRoundtripWorks() 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); + 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, @@ -3549,23 +4833,35 @@ public void NewPlanMatrixSerializationRoundtripWorks() 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); + 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() { @@ -3604,23 +4900,35 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() 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); + 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() { @@ -3659,23 +4967,35 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() 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); + 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() { @@ -3725,21 +5045,25 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() 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); + 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", @@ -3750,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, @@ -3780,24 +5112,35 @@ public void NewPlanGroupedTieredSerializationRoundtripWorks() 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); + 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() { @@ -3846,23 +5189,35 @@ public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() 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); + 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() { @@ -3898,23 +5253,35 @@ public void NewPlanPackageWithAllocationSerializationRoundtripWorks() 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); + 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", @@ -3945,22 +5312,35 @@ public void NewPlanUnitWithPercentSerializationRoundtripWorks() 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); + 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", @@ -3968,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, @@ -3998,11 +5377,15 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() 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); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -4010,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" }] @@ -4046,23 +5438,35 @@ public void TieredWithProrationSerializationRoundtripWorks() 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); + 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", @@ -4093,21 +5497,25 @@ public void NewPlanUnitWithProrationSerializationRoundtripWorks() 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); + 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", @@ -4115,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, @@ -4145,19 +5561,23 @@ public void NewPlanGroupedAllocationSerializationRoundtripWorks() 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); + 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( [ @@ -4165,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, @@ -4197,21 +5625,25 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() 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); + 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", @@ -4219,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, @@ -4250,21 +5689,25 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() 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); + 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", @@ -4272,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, @@ -4312,11 +5762,15 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() 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); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -4324,7 +5778,7 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() [Fact] public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - Price value = new GroupedWithMinMaxThresholds() + LicenseAllocationPrice value = new GroupedWithMinMaxThresholds() { Cadence = GroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() @@ -4335,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, @@ -4364,22 +5827,35 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() 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); + 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", @@ -4393,7 +5869,6 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() }, ], }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4423,21 +5898,25 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() 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); + 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", @@ -4449,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, @@ -4479,22 +5966,35 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() 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); + 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", @@ -4505,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, @@ -4535,24 +6034,35 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() 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); + 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() { @@ -4567,6 +6077,7 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -4598,24 +6109,35 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() 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); + 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() { @@ -4664,21 +6186,25 @@ public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() 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); + 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 = @@ -4693,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, @@ -4723,11 +6257,15 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() 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); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -4735,7 +6273,7 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() [Fact] public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - Price value = new CumulativeGroupedAllocation() + LicenseAllocationPrice value = new CumulativeGroupedAllocation() { Cadence = CumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() @@ -4746,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, @@ -4775,70 +6322,36 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() 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 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); + 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, @@ -4868,11 +6381,15 @@ public void NewPlanMinimumCompositeSerializationRoundtripWorks() 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); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -4880,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", @@ -4914,11 +6440,15 @@ public void PercentSerializationRoundtripWorks() 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); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -4926,7 +6456,7 @@ public void PercentSerializationRoundtripWorks() [Fact] public void EventOutputSerializationRoundtripWorks() { - Price value = new EventOutput() + LicenseAllocationPrice value = new EventOutput() { Cadence = EventOutputCadence.Annual, EventOutputConfig = new() @@ -4936,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, @@ -4965,35 +6504,40 @@ public void EventOutputSerializationRoundtripWorks() 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); + 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() @@ -5022,23 +6566,29 @@ public void FieldRoundtrip_Works() 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 = 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() @@ -5068,14 +6618,20 @@ public void FieldRoundtrip_Works() 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(expectedUnitConfig, model.UnitConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -5087,6 +6643,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) @@ -5101,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() @@ -5143,15 +6701,13 @@ public void SerializationRoundtrip_Works() 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 - ); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -5159,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() @@ -5201,30 +6758,33 @@ public void FieldRoundtripThroughSerialization_Works() 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 - ); + 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() @@ -5254,14 +6814,20 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedUnitConfig, deserialized.UnitConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -5276,6 +6842,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) @@ -5290,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() @@ -5332,6 +6900,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5342,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); @@ -5380,6 +6950,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); @@ -5389,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(); @@ -5411,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, @@ -5437,6 +7011,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -5463,6 +7038,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); @@ -5472,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, @@ -5498,197 +7076,173 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } -} - -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() + public void CopyConstructor_Works() { - var model = new BulkWithFiltersConfig + var model = new Unit { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + 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); - - 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" }, - ], - }; + Unit copied = new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class FilterTest : 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 Filter { PropertyKey = "x", PropertyValue = "x" }; - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); + // 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 Filter { PropertyKey = "x", PropertyValue = "x" }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + 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 Filter { PropertyKey = "x", PropertyValue = "x" }; - - 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 expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); - model.Validate(); + 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); } @@ -5696,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(); } @@ -5720,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(); } @@ -5737,94 +7306,45 @@ 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(); } -} - -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) + public void CopyConstructor_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>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - [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 - ); + LicenseAllocation copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } @@ -5905,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() @@ -5946,18 +7485,37 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - TieredWithProrationCadence.Annual; + ApiEnum expectedCadence = TieredCadence.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" }] - ); + 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() @@ -5966,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, @@ -5987,14 +7545,20 @@ public void FieldRoundtrip_Works() 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(expectedTieredConfig, model.TieredConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -6006,6 +7570,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) @@ -6020,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() @@ -6056,15 +7640,13 @@ public void SerializationRoundtrip_Works() 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 - ); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -6072,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() @@ -6108,25 +7709,41 @@ public void FieldRoundtripThroughSerialization_Works() 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 - ); + 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() @@ -6135,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, @@ -6156,14 +7773,20 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedTieredConfig, deserialized.TieredConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -6178,6 +7801,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) @@ -6192,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() @@ -6228,6 +7871,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6238,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); @@ -6270,6 +7933,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); @@ -6279,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(); @@ -6295,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, @@ -6315,6 +8018,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6341,6 +8045,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); @@ -6350,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, @@ -6370,34 +8095,103 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() 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 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 ); @@ -6407,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 ); @@ -6430,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 ); @@ -6444,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 ); @@ -6486,120 +8281,110 @@ 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(); } -} -public class TieredWithProrationConfigTierTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var model = new TieredLicenseAllocation { Amount = "amount", Currency = "currency" }; - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredLicenseAllocation { Amount = "amount", Currency = "currency" }; + + 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", - }; + Amount = "amount", + Currency = "currency", - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + WriteOffOverage = null, + }; - Assert.Equal(model, deserialized); + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new TieredWithProrationConfigTier + var model = new TieredLicenseAllocation { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + Amount = "amount", + Currency = "currency", - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + WriteOffOverage = null, + }; - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + model.Validate(); } [Fact] - public void Validation_Works() + 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, }; - model.Validate(); + 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"), @@ -6610,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 ); @@ -6648,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 ); @@ -6673,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, @@ -6718,23 +8504,26 @@ public void FieldRoundtrip_Works() 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"; - 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; @@ -6744,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, @@ -6765,15 +8554,18 @@ public void FieldRoundtrip_Works() 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( - 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); @@ -6787,6 +8579,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) @@ -6801,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, @@ -6841,15 +8637,13 @@ public void SerializationRoundtrip_Works() 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 - ); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -6857,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, @@ -6897,30 +8694,30 @@ public void FieldRoundtripThroughSerialization_Works() 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 - ); + 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; @@ -6930,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, @@ -6951,15 +8748,18 @@ public void FieldRoundtripThroughSerialization_Works() 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( - 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); @@ -6976,6 +8776,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) @@ -6990,17 +8791,20 @@ 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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7030,6 +8834,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7040,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", }; @@ -7076,6 +8884,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); @@ -7085,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", }; @@ -7105,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, @@ -7129,6 +8945,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7155,6 +8972,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); @@ -7164,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, @@ -7188,34 +9010,91 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() 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 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 ); @@ -7225,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); } @@ -7247,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 ); @@ -7307,97 +9184,150 @@ 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(); } + + [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 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); } @@ -7405,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, @@ -7476,23 +9415,32 @@ public void FieldRoundtrip_Works() 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() + 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; @@ -7502,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, @@ -7523,15 +9471,18 @@ public void FieldRoundtrip_Works() 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( - 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); @@ -7545,6 +9496,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) @@ -7559,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, @@ -7599,12 +9562,13 @@ public void SerializationRoundtrip_Works() 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 ); @@ -7615,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, @@ -7655,30 +9630,39 @@ public void FieldRoundtripThroughSerialization_Works() 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); - ApiEnum expectedCadence = - CumulativeGroupedAllocationCadence.Annual; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig expectedBulkWithFiltersConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + 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; @@ -7688,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, @@ -7709,15 +9693,18 @@ public void FieldRoundtripThroughSerialization_Works() 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( - 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); @@ -7734,6 +9721,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) @@ -7748,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, @@ -7788,6 +9787,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7798,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", }; @@ -7834,6 +9845,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); @@ -7843,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", }; @@ -7863,17 +9887,28 @@ 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", + 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, @@ -7887,6 +9922,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7913,6 +9949,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); @@ -7922,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, @@ -7946,115 +9995,128 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } -} - -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) + public void CopyConstructor_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); - } + 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", + }; - [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); + BulkWithFilters copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } -public class CumulativeGroupedAllocationConfigTest : TestBase +public class BulkWithFiltersConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersConfig { - 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" }, + ], }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + 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(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + 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 CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersConfig { - 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" }, + ], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8065,284 +10127,158 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersConfig { - 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" }, + ], }; 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"; + 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(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + 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 CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersConfig { - 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" }, + ], }; 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 CumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class FilterTest : TestBase { [Fact] - public void UnitValidationWorks() + public void FieldRoundtrip_Works() { - CumulativeGroupedAllocationConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); + 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 TieredValidationWorks() + public void SerializationRoundtrip_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 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 UnitSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_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 Filter { PropertyKey = "x", PropertyValue = "x" }; - Assert.Equal(value, deserialized); + 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 TieredSerializationRoundtripWorks() + public void Validation_Works() { - 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 - ); + var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; - Assert.Equal(value, deserialized); + 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 MinimumTest : TestBase +public class TierTest : 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", - }; + var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; - 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)); + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); } [Fact] public void SerializationRoundtrip_Works() { - var model = new 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", - }; + 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); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -8350,162 +10286,23 @@ public void SerializationRoundtrip_Works() [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", - }; + 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 - ); + 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)); + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); } [Fact] public void Validation_Works() { - var model = new 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", - }; + var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; model.Validate(); } @@ -8513,52 +10310,16 @@ public void Validation_Works() [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", - }; + var model = new Tier { UnitAmount = "unit_amount" }; - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; + var model = new Tier { UnitAmount = "unit_amount" }; model.Validate(); } @@ -8566,105 +10327,61 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Minimum + var model = new Tier { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + UnitAmount = "unit_amount", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + TierLowerBound = null, }; - 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.TierLowerBound); + Assert.True(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Minimum + var model = new Tier { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + UnitAmount = "unit_amount", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + TierLowerBound = null, }; model.Validate(); } + + [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 MinimumCadenceTest : TestBase +public class BulkWithFiltersCadenceTest : 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(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 ); @@ -8674,19 +10391,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(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>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -8697,12 +10414,12 @@ public void SerializationRoundtrip_Works(MinimumCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -8711,27 +10428,39 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class MinimumConfigTest : TestBase +public class BulkWithFiltersLicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8742,83 +10471,118 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new BulkWithFiltersLicenseAllocation + { + 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 expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new MinimumConfig + var model = new BulkWithFiltersLicenseAllocation { - MinimumAmount = "minimum_amount", + Amount = "amount", + Currency = "currency", - // Null should be interpreted as omitted for these properties - Prorated = null, + WriteOffOverage = null, }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new MinimumConfig + var model = new BulkWithFiltersLicenseAllocation { - MinimumAmount = "minimum_amount", + Amount = "amount", + Currency = "currency", - // Null should be interpreted as omitted for these properties - Prorated = null, + 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 MinimumConversionRateConfigTest : TestBase +public class BulkWithFiltersConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + BulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -8829,7 +10593,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + BulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -8849,13 +10613,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + BulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8866,7 +10630,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + BulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -8881,7 +10645,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8890,17 +10654,26 @@ public void TieredSerializationRoundtripWorks() } } -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,15 +10702,29 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, 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() @@ -8946,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, @@ -8967,14 +10754,20 @@ public void FieldRoundtrip_Works() 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(expectedPackageConfig, model.PackageConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -8986,6 +10779,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) @@ -9000,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() @@ -9034,12 +10837,13 @@ public void SerializationRoundtrip_Works() 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); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -9047,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() @@ -9081,22 +10894,36 @@ public void FieldRoundtripThroughSerialization_Works() 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); - 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 +10932,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PercentConversionRateConfig expectedConversionRateConfig = + PackageConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9126,14 +10953,20 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedPackageConfig, deserialized.PackageConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -9148,6 +10981,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) @@ -9162,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() @@ -9196,6 +11039,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9206,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); @@ -9236,6 +11089,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); @@ -9245,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(); @@ -9259,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, @@ -9277,6 +11150,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9303,6 +11177,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); @@ -9312,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, @@ -9330,34 +11215,91 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } -} -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) + [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; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -9367,19 +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 ); @@ -9390,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 ); @@ -9404,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 ); @@ -9433,35 +11389,110 @@ 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(); } + + [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 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"), @@ -9472,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( @@ -9492,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 ); @@ -9509,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( @@ -9524,7 +11555,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9533,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, @@ -9577,19 +11617,29 @@ public void FieldRoundtrip_Works() 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() + 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; @@ -9599,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, @@ -9620,12 +11670,18 @@ public void FieldRoundtrip_Works() 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.Equal(expectedMatrixConfig, model.MatrixConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -9639,6 +11695,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) @@ -9653,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, @@ -9692,15 +11758,13 @@ public void SerializationRoundtrip_Works() 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 - ); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -9708,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, @@ -9747,26 +11820,33 @@ public void FieldRoundtripThroughSerialization_Works() 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 - ); + 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; @@ -9776,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, @@ -9797,12 +11877,18 @@ public void FieldRoundtripThroughSerialization_Works() 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.Equal(expectedMatrixConfig, deserialized.MatrixConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -9819,6 +11905,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) @@ -9833,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, @@ -9872,6 +11968,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9882,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", }; @@ -9917,6 +12023,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); @@ -9926,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", }; @@ -9945,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, @@ -9968,6 +12094,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9994,6 +12121,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); @@ -10003,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, @@ -10026,34 +12164,96 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() 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 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 ); @@ -10063,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 ); @@ -10086,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 ); @@ -10100,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 ); @@ -10143,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(); @@ -10182,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(); } @@ -10201,41 +12399,54 @@ 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(); } + + [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 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"), @@ -10246,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( @@ -10266,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 ); @@ -10283,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( @@ -10298,7 +12509,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10307,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 ); @@ -10338,96 +12739,595 @@ 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; - - 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 + 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() { - AdjustmentID = "adjustment_id", - - PlanPhaseOrder = null, + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, }; - - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new RemoveAdjustment + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() { - AdjustmentID = "adjustment_id", - - PlanPhaseOrder = null, + 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 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 ); @@ -10438,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(); } @@ -10465,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(); } @@ -10482,121 +13402,93 @@ 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(); } -} -public class ReplaceAdjustmentTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountLicenseAllocation { - 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, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - ReplaceAdjustmentAdjustment expectedAdjustment = new Models::NewPercentageDiscount() + ThresholdTotalAmountLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ThresholdTotalAmountConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + 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 ); @@ -10607,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(); @@ -10703,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(); @@ -10766,326 +13581,169 @@ 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(); } -} -public class ReplaceAdjustmentAdjustmentTest : TestBase -{ [Fact] - public void NewPercentageDiscountValidationWorks() + public void CopyConstructor_Works() { - ReplaceAdjustmentAdjustment value = 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, }; - value.Validate(); + + ThresholdTotalAmountConfig copied = new(model); + + Assert.Equal(model, copied); } +} +public class ConsumptionTableTest : TestBase +{ [Fact] - public void NewUsageDiscountValidationWorks() + public void FieldRoundtrip_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 expectedThreshold = "threshold"; + string expectedTotalAmount = "total_amount"; + + Assert.Equal(expectedThreshold, model.Threshold); + Assert.Equal(expectedTotalAmount, model.TotalAmount); } [Fact] - public void NewAmountDiscountValidationWorks() + public void SerializationRoundtrip_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 json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewMinimumValidationWorks() + public void FieldRoundtripThroughSerialization_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" }; + + 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 NewMaximumValidationWorks() + public void Validation_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" }; + + model.Validate(); } [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() + public void CopyConstructor_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, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; - Assert.Equal(value, deserialized); + ConsumptionTable copied = new(model); + + Assert.Equal(model, copied); } +} +public class ThresholdTotalAmountConversionRateConfigTest : TestBase +{ [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() + public void UnitValidationWorks() { - 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); + ThresholdTotalAmountConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); } [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() + public void TieredValidationWorks() { - 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); + ThresholdTotalAmountConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); } [Fact] - public void NewMinimumSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - 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, - }; + 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 ); @@ -11094,30 +13752,25 @@ public void NewMinimumSerializationRoundtripWorks() } [Fact] - public void NewMaximumSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - 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, - }; + 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 ); @@ -11126,111 +13779,34 @@ public void NewMaximumSerializationRoundtripWorks() } } -public class ReplacePriceTest : TestBase +public class TieredPackageTest : 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", - 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", - }, - }; - - 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", - 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() @@ -11259,89 +13835,160 @@ public void FieldRoundtrip_Works() 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(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", - 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, - }, - 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 ); @@ -11352,113 +13999,186 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_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", - 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, - }, - 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 element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedReplacesPriceID = "replaces_price_id"; - Models::NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + ApiEnum expectedCadence = TieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - ExpiresAtEndOfCadence = true, - Filters = + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_package"); + string expectedName = "Annual fee"; + TieredPackageConfig expectedTieredPackageConfig = 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", - PerUnitCostBasis = "per_unit_cost_basis", }; - long expectedPlanPhaseOrder = 0; - ReplacePricePrice expectedPrice = new Models::NewPlanUnitPrice() + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + 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", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], 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() @@ -11487,107 +14207,99 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedPrice, deserialized.Price); + model.Validate(); } [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_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 = - [ - 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() + ], + Name = "Annual fee", + TieredPackageConfig = 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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 OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new ReplacePrice { ReplacesPriceID = "replaces_price_id" }; - - 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(); } @@ -11595,106 +14307,147 @@ 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 - { - ReplacesPriceID = "replaces_price_id", - - AllocationPrice = null, - PlanPhaseOrder = null, - Price = null, - }; - - model.Validate(); - } -} - -public class ReplacePricePriceTest : TestBase -{ - [Fact] - public void NewPlanUnitValidationWorks() - { - ReplacePricePrice value = new Models::NewPlanUnitPrice() + var model = new TieredPackage { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = TieredPackageCadence.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() + TieredPackageConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanTieredValidationWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanTieredPrice() + var model = new TieredPackage { - Cadence = Models::NewPlanTieredPriceCadence.Annual, + Cadence = TieredPackageCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredConfig = new() + TieredPackageConfig = new() { + PackageSize = "package_size", Tiers = [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], - Prorated = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -11724,312 +14477,527 @@ public void NewPlanTieredValidationWorks() 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 NewPlanBulkValidationWorks() + public void InvalidEnumValidationThrows_Works() { - ReplacePricePrice 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + 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 BulkWithFiltersValidationWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - ReplacePricePrice value = 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", - }; - value.Validate(); + 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 NewPlanPackageValidationWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanPackagePrice() + var model = new TieredPackageLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - value.Validate(); + + 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 NewPlanMatrixValidationWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixPrice() + var model = new TieredPackageLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - value.Validate(); + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewPlanThresholdTotalAmountValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() + var model = new TieredPackageLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + 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 NewPlanTieredPackageValidationWorks() + public void TieredValidationWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() + TieredPackageConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( [ - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), }; value.Validate(); } [Fact] - public void NewPlanTieredWithMinimumValidationWorks() + public void UnitSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() + TieredPackageConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + 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", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredWithMinimumConfig = new() { @@ -12079,30 +15047,147 @@ public void NewPlanTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + 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 NewPlanGroupedTieredValidationWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPrice() + var model = new TieredWithMinimum { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithMinimumConfig = new() { - GroupingKey = "x", Tiers = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_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, }, - ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12131,40 +15216,56 @@ public void NewPlanGroupedTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewPlanTieredPackageWithMinimumValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() + var model = new TieredWithMinimum { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + Cadence = TieredWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredPackageWithMinimumConfig = new() + TieredWithMinimumConfig = new() { - PackageSize = 0, Tiers = [ new() { MinimumAmount = "minimum_amount", - PerUnit = "per_unit", TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, new() { MinimumAmount = "minimum_amount", - PerUnit = "per_unit", TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ], + HideZeroAmountTiers = true, + Prorate = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12194,26 +15295,156 @@ public void NewPlanTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + 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 NewPlanPackageWithAllocationValidationWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() + var model = new TieredWithMinimum { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + Cadence = TieredWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PackageWithAllocationConfig = new() + TieredWithMinimumConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + 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, @@ -12243,210 +15474,303 @@ public void NewPlanPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanUnitWithPercentValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanUnitWithPercentPrice() + var model = new TieredWithMinimum { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + Cadence = TieredWithMinimumCadence.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", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + TieredWithMinimumConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", }; - value.Validate(); + + 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 NewPlanMatrixWithAllocationValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() + var model = new TieredWithMinimum { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + Cadence = TieredWithMinimumCadence.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, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + TieredWithMinimumConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", }; - value.Validate(); + + model.Validate(); } [Fact] - public void TieredWithProrationValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - ReplacePricePrice value = new ReplacePricePriceTieredWithProration() + var model = new TieredWithMinimum { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = TieredWithMinimumCadence.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() + TieredWithMinimumConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - value.Validate(); + + 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 NewPlanUnitWithProrationValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - ReplacePricePrice value = new Models::NewPlanUnitWithProrationPrice() + var model = new TieredWithMinimum { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = TieredWithMinimumCadence.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", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + TieredWithMinimumConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanGroupedAllocationValidationWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() + var model = new TieredWithMinimum { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + Cadence = TieredWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, + 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() @@ -12475,574 +15799,746 @@ public void NewPlanGroupedAllocationValidationWorks() 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 NewPlanBulkWithProrationValidationWorks() + public void InvalidEnumValidationThrows_Works() { - ReplacePricePrice 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"), - }, + 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", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - value.Validate(); + + 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 NewPlanGroupedWithProratedMinimumValidationWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() + var model = new TieredWithMinimumLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - value.Validate(); + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewPlanGroupedWithMeteredMinimumValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + var model = new TieredWithMinimumLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - value.Validate(); + + 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 GroupedWithMinMaxThresholdsValidationWorks() + public void Validation_Works() { - ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() + var model = new TieredWithMinimumLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanMatrixWithDisplayNameValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() + var model = new TieredWithMinimumLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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(); + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void NewPlanGroupedTieredPackageValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() + var model = new TieredWithMinimumLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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(); + + model.Validate(); } [Fact] - public void NewPlanMaxGroupTieredPackageValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() + var model = new TieredWithMinimumLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + + WriteOffOverage = null, }; - value.Validate(); + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void NewPlanScalableMatrixWithUnitPricingValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + var model = new TieredWithMinimumLicenseAllocation { - 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", - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + + WriteOffOverage = null, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanScalableMatrixWithTieredPricingValidationWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + var model = new TieredWithMinimumLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - value.Validate(); + + TieredWithMinimumLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); } +} +public class TieredWithMinimumConfigTest : TestBase +{ [Fact] - public void NewPlanCumulativeGroupedBulkValidationWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() + var model = new TieredWithMinimumConfig { - 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() + 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() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + new() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, - Currency = "currency", - DimensionalPriceConfiguration = new() + ]; + 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() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ]; + 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 CumulativeGroupedAllocationValidationWorks() + public void TieredValidationWorks() { - ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() + TieredWithMinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + 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() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + 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, @@ -13072,20 +16568,124 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + 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 MinimumValidationWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new ReplacePricePriceMinimum() + var model = new GroupedTiered { - Cadence = ReplacePricePriceMinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13115,21 +16715,45 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewPlanMinimumCompositeValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() + var model = new GroupedTiered { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, + 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", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13159,68 +16783,134 @@ public void NewPlanMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); - } - [Fact] - public void PercentValidationWorks() - { - ReplacePricePrice value = new ReplacePricePricePercent() + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedCadence = GroupedTieredCadence.Annual; + GroupedTieredConfig expectedGroupedTieredConfig = new() { - Cadence = ReplacePricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = 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() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + ]; + 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"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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 expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }; - value.Validate(); + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = 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 EventOutputValidationWorks() + public void Validation_Works() { - ReplacePricePrice value = new ReplacePricePriceEventOutput() + var model = new GroupedTiered { - Cadence = ReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13250,190 +16940,247 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanUnitSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanUnitPrice() + var model = new GroupedTiered { - 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() + Cadence = GroupedTieredCadence.Annual, + GroupedTieredConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.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 NewPlanTieredSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - ReplacePricePrice value = new Models::NewPlanTieredPrice() + var model = new GroupedTiered { - Cadence = Models::NewPlanTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() + Cadence = GroupedTieredCadence.Annual, + GroupedTieredConfig = new() { + GroupingKey = "x", Tiers = [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], - Prorated = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanBulkSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - ReplacePricePrice value = new Models::NewPlanBulkPrice() + var model = new GroupedTiered { - 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() + Cadence = GroupedTieredCadence.Annual, + GroupedTieredConfig = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + 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() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() + var model = new GroupedTiered { - BulkWithFiltersConfig = new() + Cadence = GroupedTieredCadence.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 = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13463,12 +17210,60 @@ public void BulkWithFiltersSerializationRoundtripWorks() 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, + + 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 ); @@ -13476,70 +17271,486 @@ public void BulkWithFiltersSerializationRoundtripWorks() } [Fact] - public void NewPlanPackageSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - ReplacePricePrice 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, + 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 NewPlanMatrixSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixPrice() + var model = new GroupedTieredConfig { - Cadence = Models::NewPlanMatrixPriceCadence.Annual, + 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", - MatrixConfig = new() + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + 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", + }, + ], }, - ModelType = Models::NewPlanMatrixPriceModelType.Matrix, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13568,35 +17779,147 @@ public void NewPlanMatrixSerializationRoundtripWorks() 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 + + 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(value, deserialized); + 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 NewPlanThresholdTotalAmountSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() + var model = new TieredPackageWithMinimum { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + Cadence = TieredPackageWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], 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, @@ -13626,34 +17949,54 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() 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, + + 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 NewPlanTieredPackageSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() + var model = new TieredPackageWithMinimum { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + Cadence = TieredPackageWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredPackageConfig = new() + TieredPackageWithMinimumConfig = new() { - PackageSize = "package_size", + 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", + }, ], }, BillableMetricID = "billable_metric_id", @@ -13684,46 +18027,160 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() 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( + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - Assert.Equal(value, 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 NewPlanTieredWithMinimumSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() + var model = new TieredPackageWithMinimum { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + Cadence = TieredPackageWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithMinimumConfig = new() + TieredPackageWithMinimumConfig = new() { + PackageSize = 0, Tiers = [ new() { MinimumAmount = "minimum_amount", + PerUnit = "per_unit", TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", }, new() { MinimumAmount = "minimum_amount", + PerUnit = "per_unit", TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", }, ], - HideZeroAmountTiers = true, - Prorate = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13753,85 +18210,98 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() 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); + model.Validate(); } [Fact] - public void NewPlanGroupedTieredSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPrice() + var model = new TieredPackageWithMinimum { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() { - GroupingKey = "x", + PackageSize = 0, Tiers = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, ], }, - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.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 NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() + var model = 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() { @@ -13852,167 +18322,186 @@ public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() }, ], }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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); + model.Validate(); } [Fact] - public void NewPlanPackageWithAllocationSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() + var model = new TieredPackageWithMinimum { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + Cadence = TieredPackageWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, + 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() + TieredPackageWithMinimumConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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", + }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.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 NewPlanUnitWithPercentSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - ReplacePricePrice value = new Models::NewPlanUnitWithPercentPrice() + var model = new TieredPackageWithMinimum { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + Cadence = TieredPackageWithMinimumCadence.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", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + TieredPackageWithMinimumConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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", + }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() + var model = new TieredPackageWithMinimum { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + Cadence = TieredPackageWithMinimumCadence.Annual, ItemID = "item_id", - MatrixWithAllocationConfig = new() + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + 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", + }, + ], }, - ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14041,189 +18530,623 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() 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); + 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 TieredWithProrationSerializationRoundtripWorks() + public void InvalidEnumValidationThrows_Works() { - ReplacePricePrice value = new ReplacePricePriceTieredWithProration() + 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 { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + + 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); - Assert.Equal(value, 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 NewPlanUnitWithProrationSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanUnitWithProrationPrice() + var model = new TieredPackageWithMinimumLicenseAllocation { - 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() + 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() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + new() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", }, - Currency = "currency", - DimensionalPriceConfiguration = new() + ]; + + 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() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ]; + + 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", + }, + ], }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + + 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); - Assert.Equal(value, 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 NewPlanGroupedAllocationSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() + var model = new TieredPackageWithMinimumConfigTier { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() + 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() { - 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() + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + TieredPackageWithMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + 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"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + }; + 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() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + 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 PackageWithAllocationTest : TestBase +{ [Fact] - public void NewPlanBulkWithProrationSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() + var model = new PackageWithAllocation { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + Cadence = PackageWithAllocationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, + 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() @@ -14252,99 +19175,122 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() 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() - { - ReplacePricePrice 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() + ApiEnum expectedCadence = + PackageWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + ]; + 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"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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 expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; - Assert.Equal(value, deserialized); + 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 NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + var model = new PackageWithAllocation { - 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" }, - ], - }, + Cadence = PackageWithAllocationCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + 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() @@ -14373,33 +19319,43 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() 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, + + 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 GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() + var model = new PackageWithAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + 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() @@ -14428,40 +19384,132 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() 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( + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - Assert.Equal(value, 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 NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() + var model = new PackageWithAllocation { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + Cadence = PackageWithAllocationCadence.Annual, ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14490,96 +19538,233 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() 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); + model.Validate(); } [Fact] - public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() + var model = new PackageWithAllocation { - Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() { - GroupingKey = "x", + 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" }, - ], }, + }; + + 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", - ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + PackageWithAllocationConfig = new() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", }, - Currency = "currency", - DimensionalPriceConfiguration = new() + }; + + 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() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + + BillableMetricID = null, + BilledInAdvance = null, + 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() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() + var model = new PackageWithAllocation { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + Cadence = PackageWithAllocationCadence.Annual, ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() { - GroupingKey = "x", + Allocation = "allocation", + PackageAmount = "package_amount", 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() @@ -14608,175 +19793,426 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() 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); + PackageWithAllocation copied = new(model); + + Assert.Equal(model, copied); } +} - [Fact] - public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() - { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() +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 { - 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", - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + + 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); - Assert.Equal(value, 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 NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + var model = new PackageWithAllocationLicenseAllocation { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + 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() { - 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() + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PackageWithAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + 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"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + }; + 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() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + 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 UnitWithPercentTest : TestBase +{ [Fact] - public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() + var model = new UnitWithPercent { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }, + Cadence = UnitWithPercentCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + 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() @@ -14805,33 +20241,113 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() 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); + 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 CumulativeGroupedAllocationSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() + var model = new UnitWithPercent { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + 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() @@ -14860,27 +20376,38 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() 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, + + 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 MinimumSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new ReplacePricePriceMinimum() + var model = new UnitWithPercent { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = UnitWithPercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + 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() @@ -14909,424 +20436,36 @@ public void MinimumSerializationRoundtripWorks() 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( + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - 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; + ApiEnum expectedCadence = UnitWithPercentCadence.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() + List expectedLicenseAllocations = + [ + new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - 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() + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + string expectedName = "Annual fee"; + UnitWithPercentConfig expectedUnitWithPercentConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Percent = "percent", + UnitAmount = "unit_amount", }; - 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() @@ -15335,7 +20474,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + UnitWithPercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -15356,14 +20495,20 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedUnitWithPercentConfig, deserialized.UnitWithPercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -15378,6 +20523,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) @@ -15392,20 +20538,21 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new UnitWithPercent { - 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, + 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() @@ -15434,6 +20581,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15444,20 +20592,21 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new UnitWithPercent { - 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, + 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); @@ -15482,6 +20631,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); @@ -15491,20 +20642,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new UnitWithPercent { - 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, + 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(); @@ -15513,20 +20665,21 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new UnitWithPercent { - 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, + 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, @@ -15539,6 +20692,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -15565,6 +20719,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); @@ -15574,20 +20730,21 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new UnitWithPercent { - 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, + 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, @@ -15600,70 +20757,173 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } -} -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + var model = new UnitWithPercent { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, ], - }; - - 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" }, - ]; + 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", + }; - 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++) + 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 { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + var model = new UnitWithPercentLicenseAllocation { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + 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); } @@ -15671,170 +20931,136 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + var model = new UnitWithPercentLicenseAllocation { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + 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); - 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" }, - ]; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - 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(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + var model = new UnitWithPercentLicenseAllocation { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; model.Validate(); } -} -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + var model = new UnitWithPercentLicenseAllocation { - PropertyKey = "x", - PropertyValue = "x", + Amount = "amount", + Currency = "currency", }; - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void SerializationRoundtrip_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + var model = new UnitWithPercentLicenseAllocation { - PropertyKey = "x", - PropertyValue = "x", + Amount = "amount", + Currency = "currency", }; - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + model.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + var model = new UnitWithPercentLicenseAllocation { - PropertyKey = "x", - PropertyValue = "x", + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, }; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + WriteOffOverage = null, + }; + + model.Validate(); } [Fact] - public void Validation_Works() + public void CopyConstructor_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + var model = new UnitWithPercentLicenseAllocation { - PropertyKey = "x", - PropertyValue = "x", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - model.Validate(); + UnitWithPercentLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); } } -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase +public class UnitWithPercentConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; + var model = new UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; + string expectedPercent = "percent"; string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + Assert.Equal(expectedPercent, model.Percent); 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", - }; + var model = new UnitWithPercentConfig { Percent = "percent", 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); } @@ -15842,248 +21068,76667 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; + var model = new UnitWithPercentConfig { Percent = "percent", 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 expectedPercent = "percent"; string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + Assert.Equal(expectedPercent, deserialized.Percent); 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", - }; + var model = new UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + 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() { - UnitAmount = "unit_amount", + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; + value.Validate(); + } - Assert.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + [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 OptionalNullablePropertiesUnsetValidation_Works() + public void UnitSerializationRoundtripWorks() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + UnitWithPercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - UnitAmount = "unit_amount", + 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 OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void TieredSerializationRoundtripWorks() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + UnitWithPercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - UnitAmount = "unit_amount", - - TierLowerBound = null, + 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.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + Assert.Equal(value, deserialized); } +} +public class MatrixWithAllocationTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new MatrixWithAllocation { - UnitAmount = "unit_amount", + 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", + }; - TierLowerBound = null, + 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"; - model.Validate(); + 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); } -} -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() + { + 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] + public void NewPlanUnitValidationWorks() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice value = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanPackageValidationWorks() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice value = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanUnitWithProrationValidationWorks() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice value = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanMatrixWithDisplayNameValidationWorks() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + 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, + }, + LicenseTypeID = "license_type_id", + 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, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + 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() + { + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void EventOutputValidationWorks() + { + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanUnitSerializationRoundtripWorks() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice value = 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, + }, + 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice value = 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, + }, + 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice value = 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, + }, + 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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 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) + public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() { - // 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); + ReplacePricePrice 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 InvalidEnumSerializationRoundtrip_Works() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - 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); + 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, + }, + 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 ReplacePricePriceBulkWithFiltersConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void NewPlanMinimumCompositeSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() + 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"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() + }, + Currency = "currency", + DimensionalPriceConfiguration = new() { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = 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 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, + }, + 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 - ); + 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, + }, + 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 - ); + 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() @@ -16112,17 +97757,25 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - ReplacePricePriceTieredWithProrationCadence.Annual; + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = + ReplacePricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -16131,7 +97784,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16152,14 +97805,15 @@ public void FieldRoundtrip_Works() 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(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -16171,6 +97825,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) @@ -16185,14 +97840,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() @@ -16221,12 +97882,13 @@ public void SerializationRoundtrip_Works() 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 ); @@ -16237,14 +97899,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() @@ -16273,24 +97941,32 @@ public void FieldRoundtripThroughSerialization_Works() 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); - ApiEnum expectedCadence = - ReplacePricePriceTieredWithProrationCadence.Annual; + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = + ReplacePricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -16299,7 +97975,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16320,14 +97996,15 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -16342,6 +98019,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) @@ -16356,14 +98034,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() @@ -16392,6 +98076,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16402,14 +98087,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); @@ -16434,6 +98125,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); @@ -16443,14 +98136,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -16459,14 +98158,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, @@ -16479,6 +98184,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -16505,6 +98211,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); @@ -16514,14 +98222,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_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, @@ -16534,91 +98248,100 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } -} - -public class ReplacePricePriceTieredWithProrationCadenceTest : 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) - { - // 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(ReplacePricePriceTieredWithProrationCadence.Annual)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Monthly)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Quarterly)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.OneTime)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Custom)] - public void SerializationRoundtrip_Works(ReplacePricePriceTieredWithProrationCadence rawValue) + public void CopyConstructor_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); - } + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; - [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); + ReplacePricePriceBulkWithFilters copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } -public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; - List expectedTiers = + List expectedFilters = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ]; + Assert.Equal(expectedFilters.Count, model.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], model.Filters[i]); + } Assert.Equal(expectedTiers.Count, model.Tiers.Count); for (int i = 0; i < expectedTiers.Count; i++) { @@ -16629,14 +98352,19 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -16647,24 +98375,39 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - List expectedTiers = + List expectedFilters = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ]; + Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], deserialized.Filters[i]); + } Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); for (int i = 0; i < expectedTiers.Count; i++) { @@ -16675,45 +98418,156 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; model.Validate(); } + + [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 ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + 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(); + } + + [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 +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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 ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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 ); @@ -16724,46 +98578,172 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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 expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); } [Fact] public void Validation_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + 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(); } + + [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 ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase +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() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16775,7 +98755,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16796,7 +98776,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16804,7 +98784,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16815,7 +98795,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16832,7 +98812,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16841,23 +98821,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() @@ -16886,25 +98862,18 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + ApiEnum expectedCadence = + ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -16913,7 +98882,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16934,17 +98903,15 @@ public void FieldRoundtrip_Works() 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(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -16956,6 +98923,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) @@ -16970,18 +98938,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() @@ -17010,12 +98974,13 @@ public void SerializationRoundtrip_Works() 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 ); @@ -17026,18 +98991,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() @@ -17066,32 +99027,25 @@ public void FieldRoundtripThroughSerialization_Works() 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); - ApiEnum expectedCadence = - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + ApiEnum expectedCadence = + ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -17100,7 +99054,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17121,17 +99075,15 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -17146,6 +99098,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) @@ -17160,18 +99113,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() @@ -17200,6 +99149,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17210,18 +99160,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); @@ -17246,6 +99192,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); @@ -17255,18 +99203,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceTieredWithProration { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -17275,18 +99219,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, @@ -17299,6 +99239,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17325,6 +99266,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); @@ -17334,18 +99277,14 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_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, @@ -17358,27 +99297,77 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePricePriceTieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase +public class ReplacePricePriceTieredWithProrationCadenceTest : TestBase { [Theory] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] - public void Validation_Works(ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue) + [InlineData(ReplacePricePriceTieredWithProrationCadence.Annual)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Monthly)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Quarterly)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.OneTime)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Custom)] + public void Validation_Works(ReplacePricePriceTieredWithProrationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -17386,7 +99375,7 @@ public void Validation_Works(ReplacePricePriceGroupedWithMinMaxThresholdsCadence public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -17394,22 +99383,20 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] - public void SerializationRoundtrip_Works( - ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue - ) + [InlineData(ReplacePricePriceTieredWithProrationCadence.Annual)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Monthly)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Quarterly)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.OneTime)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(ReplacePricePriceTieredWithProrationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -17419,58 +99406,50 @@ ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest - : TestBase +public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } } [Fact] public void SerializationRoundtrip_Works() { - var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -17481,56 +99460,150 @@ 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(); } + + [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 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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17542,7 +99615,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17563,7 +99636,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17571,7 +99644,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17582,7 +99655,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17599,7 +99672,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17608,20 +99681,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", @@ -17653,23 +99726,24 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + ApiEnum expectedCadence = + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -17680,7 +99754,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17701,13 +99775,14 @@ public void FieldRoundtrip_Works() 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 + expectedGroupedWithMinMaxThresholdsConfig, + model.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); @@ -17723,6 +99798,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) @@ -17737,15 +99813,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", @@ -17777,12 +99853,13 @@ public void SerializationRoundtrip_Works() 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 ); @@ -17793,15 +99870,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", @@ -17833,30 +99910,31 @@ public void FieldRoundtripThroughSerialization_Works() 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); - ApiEnum expectedCadence = - ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + ApiEnum expectedCadence = + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -17867,7 +99945,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17888,13 +99966,14 @@ public void FieldRoundtripThroughSerialization_Works() 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 + expectedGroupedWithMinMaxThresholdsConfig, + deserialized.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); @@ -17913,6 +99992,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) @@ -17927,15 +100007,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", @@ -17967,6 +100047,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17977,15 +100058,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", @@ -18013,6 +100094,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); @@ -18022,15 +100105,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -18042,15 +100125,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", @@ -18066,6 +100149,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18092,6 +100176,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); @@ -18101,15 +100187,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", @@ -18125,27 +100211,81 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePricePriceGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase { [Theory] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] - public void Validation_Works(ReplacePricePriceCumulativeGroupedAllocationCadence rawValue) + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works(ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -18153,7 +100293,7 @@ public void Validation_Works(ReplacePricePriceCumulativeGroupedAllocationCadence public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -18161,22 +100301,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] public void SerializationRoundtrip_Works( - ReplacePricePriceCumulativeGroupedAllocationCadence rawValue + ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -18186,58 +100326,58 @@ ReplacePricePriceCumulativeGroupedAllocationCadence rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest +public class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedMaximumCharge, model.MaximumCharge); + Assert.Equal(expectedMinimumCharge, model.MinimumCharge); + Assert.Equal(expectedPerUnitRate, model.PerUnitRate); } [Fact] public void SerializationRoundtrip_Works() { var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18249,55 +100389,74 @@ 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(); } + + [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 ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18309,7 +100468,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18330,7 +100489,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18338,7 +100497,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18349,7 +100508,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18366,7 +100525,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18375,16 +100534,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, @@ -18414,19 +100579,25 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - ReplacePricePriceMinimumCadence.Annual; + ApiEnum expectedCadence = + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -18436,7 +100607,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18457,12 +100628,16 @@ public void FieldRoundtrip_Works() 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(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -18476,6 +100651,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) @@ -18490,11 +100666,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, @@ -18524,12 +100706,13 @@ public void SerializationRoundtrip_Works() 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 ); @@ -18540,11 +100723,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, @@ -18574,26 +100763,32 @@ public void FieldRoundtripThroughSerialization_Works() 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); - ApiEnum expectedCadence = - ReplacePricePriceMinimumCadence.Annual; + ApiEnum expectedCadence = + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -18603,7 +100798,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18624,12 +100819,16 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -18646,6 +100845,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) @@ -18660,11 +100860,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, @@ -18694,6 +100900,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18704,11 +100911,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", }; @@ -18734,6 +100947,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); @@ -18743,11 +100958,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -18757,11 +100978,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, @@ -18775,6 +101002,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18801,6 +101029,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); @@ -18810,11 +101040,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, @@ -18828,57 +101064,112 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePricePriceCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceMinimumCadenceTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase { [Theory] - [InlineData(ReplacePricePriceMinimumCadence.Annual)] - [InlineData(ReplacePricePriceMinimumCadence.SemiAnnual)] - [InlineData(ReplacePricePriceMinimumCadence.Monthly)] - [InlineData(ReplacePricePriceMinimumCadence.Quarterly)] - [InlineData(ReplacePricePriceMinimumCadence.OneTime)] - [InlineData(ReplacePricePriceMinimumCadence.Custom)] - public void Validation_Works(ReplacePricePriceMinimumCadence rawValue) + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + public void Validation_Works(ReplacePricePriceCumulativeGroupedAllocationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(ReplacePricePriceMinimumCadence.Annual)] - [InlineData(ReplacePricePriceMinimumCadence.SemiAnnual)] - [InlineData(ReplacePricePriceMinimumCadence.Monthly)] - [InlineData(ReplacePricePriceMinimumCadence.Quarterly)] - [InlineData(ReplacePricePriceMinimumCadence.OneTime)] - [InlineData(ReplacePricePriceMinimumCadence.Custom)] - public void SerializationRoundtrip_Works(ReplacePricePriceMinimumCadence rawValue) + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePricePriceCumulativeGroupedAllocationCadence rawValue + ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -18887,51 +101178,62 @@ public void SerializationRoundtrip_Works(ReplacePricePriceMinimumCadence rawValu [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceMinimumMinimumConfigTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -18939,91 +101241,75 @@ 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" }; + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void CopyConstructor_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", + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = new( + model + ); - model.Validate(); + Assert.Equal(model, copied); } } -public class ReplacePricePriceMinimumConversionRateConfigTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19035,7 +101321,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19056,17 +101342,18 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -19074,7 +101361,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19090,10 +101377,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); } @@ -19138,6 +101426,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19177,6 +101466,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"; @@ -19196,6 +101486,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) @@ -19244,6 +101535,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19294,6 +101586,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19340,6 +101633,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"; @@ -19362,6 +101656,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) @@ -19410,6 +101705,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19450,6 +101746,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); @@ -19491,6 +101789,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19517,6 +101816,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); @@ -19544,12 +101845,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePricePricePercent copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePricePercentCadenceTest : TestBase @@ -19666,6 +102015,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 @@ -19793,6 +102152,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19837,6 +102197,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"; @@ -19856,6 +102217,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) @@ -19909,6 +102271,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19964,6 +102327,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20015,6 +102379,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"; @@ -20037,6 +102402,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) @@ -20090,6 +102456,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20135,6 +102502,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); @@ -20186,6 +102555,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20212,6 +102582,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); @@ -20244,12 +102616,65 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePricePriceEventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceEventOutputCadenceTest : TestBase @@ -20444,6 +102869,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/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..d42fae976 100644 --- a/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs +++ b/src/Orb.Tests/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParamsTest.cs @@ -70,8 +70,57 @@ public void FieldRoundtrip_Works() }, ], 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, Price = new Models::NewPlanUnitPrice() { @@ -109,6 +158,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -171,8 +221,57 @@ public void FieldRoundtrip_Works() }, ], 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() { @@ -210,6 +309,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -272,8 +372,57 @@ public void FieldRoundtrip_Works() }, ], 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, Price = new Models::NewPlanUnitPrice() { @@ -311,6 +460,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -378,8 +528,57 @@ public void FieldRoundtrip_Works() }, ], 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() { @@ -417,6 +616,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -539,6 +739,319 @@ 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", + 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() + { + 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", + }, + }, + ], + 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", + 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", + }, + }, + ], + SetAsDefault = true, + }; + + ExternalPlanIDCreatePlanVersionParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class AddAdjustmentTest : TestBase @@ -851,6 +1364,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 @@ -1176,8 +1722,57 @@ public void FieldRoundtrip_Works() }, ], 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, Price = new Models::NewPlanUnitPrice() { @@ -1215,6 +1810,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1241,8 +1837,56 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + 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() { @@ -1279,11 +1923,13 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; Assert.Equal(expectedAllocationPrice, model.AllocationPrice); + Assert.Equal(expectedLicenseAllocationPrice, model.LicenseAllocationPrice); Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); Assert.Equal(expectedPrice, model.Price); } @@ -1314,8 +1960,57 @@ public void SerializationRoundtrip_Works() }, ], 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, Price = new Models::NewPlanUnitPrice() { @@ -1353,6 +2048,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1390,8 +2086,57 @@ public void FieldRoundtripThroughSerialization_Works() }, ], 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, Price = new Models::NewPlanUnitPrice() { @@ -1429,6 +2174,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1462,8 +2208,56 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + 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() { @@ -1500,11 +2294,13 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); + Assert.Equal(expectedLicenseAllocationPrice, deserialized.LicenseAllocationPrice); Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); Assert.Equal(expectedPrice, deserialized.Price); } @@ -1535,8 +2331,57 @@ public void Validation_Works() }, ], 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, Price = new Models::NewPlanUnitPrice() { @@ -1574,6 +2419,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1589,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); @@ -1609,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); @@ -1627,24 +2478,158 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() var model = new AddPrice { AllocationPrice = null, + LicenseAllocationPrice = null, PlanPhaseOrder = null, Price = null, }; 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", + 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() + { + 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", + }, + }; + + AddPrice copied = new(model); + + Assert.Equal(model, copied); + } } -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", @@ -1675,6 +2660,7 @@ public void NewPlanUnitValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1682,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() { @@ -1731,6 +2725,7 @@ public void NewPlanTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1738,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, @@ -1775,6 +2778,7 @@ public void NewPlanBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1784,7 +2788,7 @@ public void NewPlanBulkValidationWorks() [Fact] public void BulkWithFiltersValidationWorks() { - Price value = new BulkWithFilters() + LicenseAllocationPrice value = new BulkWithFilters() { BulkWithFiltersConfig = new() { @@ -1795,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, @@ -1826,6 +2839,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1833,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", @@ -1870,6 +2892,7 @@ public void NewPlanPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1877,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, @@ -1919,6 +2950,7 @@ public void NewPlanMatrixValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1926,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() { @@ -1971,6 +3011,7 @@ public void NewPlanThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1978,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() { @@ -2023,6 +3072,7 @@ public void NewPlanTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2030,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() { @@ -2086,6 +3144,7 @@ public void NewPlanTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2093,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", @@ -2108,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, @@ -2138,6 +3205,7 @@ public void NewPlanGroupedTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2145,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() { @@ -2201,6 +3276,7 @@ public void NewPlanTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2208,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() { @@ -2250,6 +3334,7 @@ public void NewPlanPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2257,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", @@ -2294,6 +3387,7 @@ public void NewPlanUnitWithPercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2301,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", @@ -2314,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, @@ -2344,6 +3446,7 @@ public void NewPlanMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2353,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" }] @@ -2389,6 +3501,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2396,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", @@ -2433,6 +3554,7 @@ public void NewPlanUnitWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2440,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", @@ -2452,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, @@ -2482,6 +3612,7 @@ public void NewPlanGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2489,9 +3620,9 @@ public void NewPlanGroupedAllocationValidationWorks() } [Fact] - public void NewPlanBulkWithProrationValidationWorks() + public void BulkWithProrationValidationWorks() { - Price value = new Models::NewPlanBulkWithProrationPrice() + LicenseAllocationPrice value = new BulkWithProration() { BulkWithProrationConfig = new( [ @@ -2499,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, @@ -2531,6 +3670,7 @@ public void NewPlanBulkWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2538,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", @@ -2550,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, @@ -2581,6 +3728,7 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2588,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", @@ -2600,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, @@ -2640,6 +3795,7 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2649,7 +3805,7 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() [Fact] public void GroupedWithMinMaxThresholdsValidationWorks() { - Price value = new GroupedWithMinMaxThresholds() + LicenseAllocationPrice value = new GroupedWithMinMaxThresholds() { Cadence = GroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() @@ -2660,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, @@ -2689,6 +3854,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2696,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", @@ -2715,7 +3890,6 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() }, ], }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2745,6 +3919,7 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2752,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", @@ -2768,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, @@ -2798,6 +3981,7 @@ public void NewPlanGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2805,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", @@ -2821,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, @@ -2851,6 +4043,7 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2858,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() { @@ -2880,6 +4080,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -2911,6 +4112,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2918,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() { @@ -2974,6 +4183,7 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2981,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 = @@ -3000,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, @@ -3030,6 +4248,7 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3039,7 +4258,7 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() [Fact] public void CumulativeGroupedAllocationValidationWorks() { - Price value = new CumulativeGroupedAllocation() + LicenseAllocationPrice value = new CumulativeGroupedAllocation() { Cadence = CumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() @@ -3050,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, @@ -3079,6 +4307,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3086,13 +4315,22 @@ public void CumulativeGroupedAllocationValidationWorks() } [Fact] - public void MinimumValidationWorks() + public void MinimumCompositeValidationWorks() { - Price value = new Minimum() + LicenseAllocationPrice value = new MinimumComposite() { - Cadence = MinimumCadence.Annual, + Cadence = MinimumCompositeCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3122,6 +4360,7 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3129,15 +4368,23 @@ public void MinimumValidationWorks() } [Fact] - public void NewPlanMinimumCompositeValidationWorks() + public void PercentValidationWorks() { - Price value = new Models::NewPlanMinimumCompositePrice() + LicenseAllocationPrice value = new Percent() { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3166,6 +4413,7 @@ public void NewPlanMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3173,14 +4421,28 @@ public void NewPlanMinimumCompositeValidationWorks() } [Fact] - public void PercentValidationWorks() + public void EventOutputValidationWorks() { - Price value = new Percent() + LicenseAllocationPrice value = new EventOutput() { - Cadence = PercentCadence.Annual, + 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", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3209,6 +4471,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3216,19 +4479,23 @@ public void PercentValidationWorks() } [Fact] - public void EventOutputValidationWorks() + public void UnitSerializationRoundtripWorks() { - Price value = new EventOutput() + LicenseAllocationPrice value = new Unit() { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + 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() @@ -3257,22 +4524,49 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", 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 NewPlanUnitSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Price value = new Models::NewPlanUnitPrice() + LicenseAllocationPrice value = new Tiered() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = TieredCadence.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 }, + TieredConfig = new() + { + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3301,83 +4595,36 @@ public void NewPlanUnitSerializationRoundtripWorks() 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, - }, - 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 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, @@ -3407,11 +4654,15 @@ public void NewPlanBulkSerializationRoundtripWorks() 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); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -3419,7 +4670,7 @@ public void NewPlanBulkSerializationRoundtripWorks() [Fact] public void BulkWithFiltersSerializationRoundtripWorks() { - Price value = new BulkWithFilters() + LicenseAllocationPrice value = new BulkWithFilters() { BulkWithFiltersConfig = new() { @@ -3430,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, @@ -3461,23 +4721,35 @@ public void BulkWithFiltersSerializationRoundtripWorks() 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); + 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", @@ -3508,29 +4780,41 @@ public void NewPlanPackageSerializationRoundtripWorks() 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); + 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, @@ -3560,23 +4844,35 @@ public void NewPlanMatrixSerializationRoundtripWorks() 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); + 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() { @@ -3615,23 +4911,35 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() 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); + 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() { @@ -3670,23 +4978,35 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() 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); + 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() { @@ -3736,21 +5056,25 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() 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); + 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", @@ -3761,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, @@ -3791,24 +5123,35 @@ public void NewPlanGroupedTieredSerializationRoundtripWorks() 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); + 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() { @@ -3857,23 +5200,35 @@ public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() 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); + 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() { @@ -3909,23 +5264,35 @@ public void NewPlanPackageWithAllocationSerializationRoundtripWorks() 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); + 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", @@ -3956,22 +5323,35 @@ public void NewPlanUnitWithPercentSerializationRoundtripWorks() 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); + 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", @@ -3979,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, @@ -4009,11 +5388,15 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() 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); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -4021,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" }] @@ -4057,23 +5449,35 @@ public void TieredWithProrationSerializationRoundtripWorks() 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); + 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", @@ -4104,21 +5508,25 @@ public void NewPlanUnitWithProrationSerializationRoundtripWorks() 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); + 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", @@ -4126,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, @@ -4156,19 +5572,23 @@ public void NewPlanGroupedAllocationSerializationRoundtripWorks() 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); + 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( [ @@ -4176,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, @@ -4208,21 +5636,25 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() 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); + 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", @@ -4230,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, @@ -4261,21 +5700,25 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() 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); + 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", @@ -4283,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, @@ -4323,11 +5773,15 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() 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); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -4335,7 +5789,7 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() [Fact] public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - Price value = new GroupedWithMinMaxThresholds() + LicenseAllocationPrice value = new GroupedWithMinMaxThresholds() { Cadence = GroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() @@ -4346,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, @@ -4375,22 +5838,35 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() 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); + 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", @@ -4404,7 +5880,6 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() }, ], }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4434,21 +5909,25 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() 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); + 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", @@ -4460,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, @@ -4490,22 +5977,35 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() 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); + 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", @@ -4516,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, @@ -4546,24 +6045,35 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() 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); + 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() { @@ -4578,6 +6088,7 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -4609,24 +6120,35 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() 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); + 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() { @@ -4675,21 +6197,25 @@ public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() 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); + 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 = @@ -4704,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, @@ -4734,11 +6268,15 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() 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); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -4746,7 +6284,7 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() [Fact] public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - Price value = new CumulativeGroupedAllocation() + LicenseAllocationPrice value = new CumulativeGroupedAllocation() { Cadence = CumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() @@ -4757,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, @@ -4786,70 +6333,36 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() 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 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); + 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, @@ -4879,11 +6392,15 @@ public void NewPlanMinimumCompositeSerializationRoundtripWorks() 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); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -4891,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", @@ -4925,11 +6451,15 @@ public void PercentSerializationRoundtripWorks() 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); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -4937,7 +6467,7 @@ public void PercentSerializationRoundtripWorks() [Fact] public void EventOutputSerializationRoundtripWorks() { - Price value = new EventOutput() + LicenseAllocationPrice value = new EventOutput() { Cadence = EventOutputCadence.Annual, EventOutputConfig = new() @@ -4947,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, @@ -4976,35 +6515,40 @@ public void EventOutputSerializationRoundtripWorks() 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); + 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() @@ -5033,23 +6577,29 @@ public void FieldRoundtrip_Works() 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 = 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() @@ -5079,14 +6629,20 @@ public void FieldRoundtrip_Works() 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(expectedUnitConfig, model.UnitConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -5098,6 +6654,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) @@ -5112,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() @@ -5154,15 +6712,13 @@ public void SerializationRoundtrip_Works() 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 - ); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -5170,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() @@ -5212,30 +6769,33 @@ public void FieldRoundtripThroughSerialization_Works() 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 - ); + 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() @@ -5265,14 +6825,20 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedUnitConfig, deserialized.UnitConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -5287,6 +6853,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) @@ -5301,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() @@ -5343,6 +6911,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5353,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); @@ -5391,6 +6961,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); @@ -5400,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(); @@ -5422,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, @@ -5448,6 +7022,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -5474,6 +7049,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); @@ -5483,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, @@ -5509,197 +7087,173 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } -} - -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() + public void CopyConstructor_Works() { - var model = new BulkWithFiltersConfig + var model = new Unit { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + 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); - - 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" }, - ], - }; + Unit copied = new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class FilterTest : 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 Filter { PropertyKey = "x", PropertyValue = "x" }; - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); + // 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 Filter { PropertyKey = "x", PropertyValue = "x" }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + 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 Filter { PropertyKey = "x", PropertyValue = "x" }; - - 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 expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); - model.Validate(); + 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); } @@ -5707,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(); } @@ -5731,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(); } @@ -5748,94 +7317,45 @@ 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(); } -} - -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) + public void CopyConstructor_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>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - [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 - ); + LicenseAllocation copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } @@ -5916,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() @@ -5957,18 +7496,37 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - TieredWithProrationCadence.Annual; + ApiEnum expectedCadence = TieredCadence.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" }] - ); + 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() @@ -5977,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, @@ -5998,14 +7556,20 @@ public void FieldRoundtrip_Works() 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(expectedTieredConfig, model.TieredConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -6017,6 +7581,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) @@ -6031,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() @@ -6067,15 +7651,13 @@ public void SerializationRoundtrip_Works() 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 - ); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -6083,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() @@ -6119,25 +7720,41 @@ public void FieldRoundtripThroughSerialization_Works() 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 - ); + 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() @@ -6146,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, @@ -6167,14 +7784,20 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedTieredConfig, deserialized.TieredConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -6189,6 +7812,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) @@ -6203,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() @@ -6239,6 +7882,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6249,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); @@ -6281,6 +7944,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); @@ -6290,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(); @@ -6306,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, @@ -6326,6 +8029,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6352,6 +8056,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); @@ -6361,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, @@ -6381,34 +8106,103 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() 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 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 ); @@ -6418,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 ); @@ -6441,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 ); @@ -6455,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 ); @@ -6497,120 +8292,110 @@ 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(); } -} -public class TieredWithProrationConfigTierTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var model = new TieredLicenseAllocation { Amount = "amount", Currency = "currency" }; - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); + } - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new TieredLicenseAllocation { Amount = "amount", Currency = "currency" }; + + 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", - }; + Amount = "amount", + Currency = "currency", - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + WriteOffOverage = null, + }; - Assert.Equal(model, deserialized); + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new TieredWithProrationConfigTier + var model = new TieredLicenseAllocation { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + Amount = "amount", + Currency = "currency", - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + WriteOffOverage = null, + }; - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + model.Validate(); } [Fact] - public void Validation_Works() + 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, }; - model.Validate(); + 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"), @@ -6621,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 ); @@ -6659,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 ); @@ -6684,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, @@ -6729,23 +8515,26 @@ public void FieldRoundtrip_Works() 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"; - 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; @@ -6755,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, @@ -6776,15 +8565,18 @@ public void FieldRoundtrip_Works() 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( - 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); @@ -6798,6 +8590,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) @@ -6812,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, @@ -6852,15 +8648,13 @@ public void SerializationRoundtrip_Works() 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 - ); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -6868,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, @@ -6908,30 +8705,30 @@ public void FieldRoundtripThroughSerialization_Works() 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 - ); + 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; @@ -6941,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, @@ -6962,15 +8759,18 @@ public void FieldRoundtripThroughSerialization_Works() 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( - 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); @@ -6987,6 +8787,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) @@ -7001,17 +8802,20 @@ 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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7041,6 +8845,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7051,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", }; @@ -7087,6 +8895,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); @@ -7096,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", }; @@ -7116,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, @@ -7140,6 +8956,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7166,6 +8983,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); @@ -7175,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, @@ -7199,34 +9021,91 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() 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 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 ); @@ -7236,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); } @@ -7258,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 ); @@ -7318,97 +9195,150 @@ 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(); } + + [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 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); } @@ -7416,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, @@ -7487,23 +9426,32 @@ public void FieldRoundtrip_Works() 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() + 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; @@ -7513,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, @@ -7534,15 +9482,18 @@ public void FieldRoundtrip_Works() 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( - 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); @@ -7556,6 +9507,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) @@ -7570,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, @@ -7610,12 +9573,13 @@ public void SerializationRoundtrip_Works() 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 ); @@ -7626,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, @@ -7666,30 +9641,39 @@ public void FieldRoundtripThroughSerialization_Works() 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); - ApiEnum expectedCadence = - CumulativeGroupedAllocationCadence.Annual; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig expectedBulkWithFiltersConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + 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; @@ -7699,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, @@ -7720,15 +9704,18 @@ public void FieldRoundtripThroughSerialization_Works() 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( - 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); @@ -7745,6 +9732,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) @@ -7759,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, @@ -7799,6 +9798,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7809,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", }; @@ -7845,6 +9856,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); @@ -7854,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", }; @@ -7874,17 +9898,28 @@ 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", + 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, @@ -7898,6 +9933,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7924,6 +9960,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); @@ -7933,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, @@ -7957,115 +10006,128 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } -} - -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) + public void CopyConstructor_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); - } + 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", + }; - [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); + BulkWithFilters copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } -public class CumulativeGroupedAllocationConfigTest : TestBase +public class BulkWithFiltersConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersConfig { - 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" }, + ], }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + 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(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + 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 CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersConfig { - 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" }, + ], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8076,284 +10138,158 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersConfig { - 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" }, + ], }; 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"; + 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(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + 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 CumulativeGroupedAllocationConfig + var model = new BulkWithFiltersConfig { - 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" }, + ], }; 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 CumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class FilterTest : TestBase { [Fact] - public void UnitValidationWorks() + public void FieldRoundtrip_Works() { - CumulativeGroupedAllocationConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); + 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 TieredValidationWorks() + public void SerializationRoundtrip_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 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 UnitSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_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 Filter { PropertyKey = "x", PropertyValue = "x" }; - Assert.Equal(value, deserialized); + 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 TieredSerializationRoundtripWorks() + public void Validation_Works() { - 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 - ); + var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; - Assert.Equal(value, deserialized); + 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 MinimumTest : TestBase +public class TierTest : 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", - }; + var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; - 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)); + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); } [Fact] public void SerializationRoundtrip_Works() { - var model = new 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", - }; + 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); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -8361,162 +10297,23 @@ public void SerializationRoundtrip_Works() [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", - }; + 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 - ); + 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)); + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); } [Fact] public void Validation_Works() { - var model = new 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", - }; + var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; model.Validate(); } @@ -8524,52 +10321,16 @@ public void Validation_Works() [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", - }; + var model = new Tier { UnitAmount = "unit_amount" }; - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Minimum - { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; + var model = new Tier { UnitAmount = "unit_amount" }; model.Validate(); } @@ -8577,105 +10338,61 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Minimum + var model = new Tier { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + UnitAmount = "unit_amount", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + TierLowerBound = null, }; - 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.TierLowerBound); + Assert.True(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Minimum + var model = new Tier { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + UnitAmount = "unit_amount", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + TierLowerBound = null, }; model.Validate(); } + + [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 MinimumCadenceTest : TestBase +public class BulkWithFiltersCadenceTest : 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(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 ); @@ -8685,19 +10402,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(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>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -8708,12 +10425,12 @@ public void SerializationRoundtrip_Works(MinimumCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -8722,27 +10439,39 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class MinimumConfigTest : TestBase +public class BulkWithFiltersLicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8753,83 +10482,118 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new BulkWithFiltersLicenseAllocation + { + 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 expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new BulkWithFiltersLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new MinimumConfig + var model = new BulkWithFiltersLicenseAllocation { - MinimumAmount = "minimum_amount", + Amount = "amount", + Currency = "currency", - // Null should be interpreted as omitted for these properties - Prorated = null, + WriteOffOverage = null, }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new MinimumConfig + var model = new BulkWithFiltersLicenseAllocation { - MinimumAmount = "minimum_amount", + Amount = "amount", + Currency = "currency", - // Null should be interpreted as omitted for these properties - Prorated = null, + 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 MinimumConversionRateConfigTest : TestBase +public class BulkWithFiltersConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + BulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -8840,7 +10604,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + BulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -8860,13 +10624,13 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + BulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8877,7 +10641,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + BulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -8892,7 +10656,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8901,17 +10665,26 @@ public void TieredSerializationRoundtripWorks() } } -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() @@ -8940,15 +10713,29 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, 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() @@ -8957,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, @@ -8978,14 +10765,20 @@ public void FieldRoundtrip_Works() 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(expectedPackageConfig, model.PackageConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -8997,6 +10790,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) @@ -9011,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() @@ -9045,12 +10848,13 @@ public void SerializationRoundtrip_Works() 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); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -9058,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() @@ -9092,22 +10905,36 @@ public void FieldRoundtripThroughSerialization_Works() 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); - 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() @@ -9116,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, @@ -9137,14 +10964,20 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedPackageConfig, deserialized.PackageConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -9159,6 +10992,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) @@ -9173,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() @@ -9207,6 +11050,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9217,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); @@ -9247,6 +11100,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); @@ -9256,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(); @@ -9270,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, @@ -9288,6 +11161,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9314,6 +11188,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); @@ -9323,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, @@ -9341,34 +11226,91 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } -} -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) + [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; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -9378,19 +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 ); @@ -9401,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 ); @@ -9415,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 ); @@ -9444,35 +11400,110 @@ 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(); } + + [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 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"), @@ -9483,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( @@ -9503,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 ); @@ -9520,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( @@ -9535,7 +11566,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9544,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, @@ -9588,19 +11628,29 @@ public void FieldRoundtrip_Works() 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() + 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; @@ -9610,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, @@ -9631,12 +11681,18 @@ public void FieldRoundtrip_Works() 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.Equal(expectedMatrixConfig, model.MatrixConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -9650,6 +11706,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) @@ -9664,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, @@ -9703,15 +11769,13 @@ public void SerializationRoundtrip_Works() 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 - ); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -9719,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, @@ -9758,26 +11831,33 @@ public void FieldRoundtripThroughSerialization_Works() 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 - ); + 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; @@ -9787,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, @@ -9808,12 +11888,18 @@ public void FieldRoundtripThroughSerialization_Works() 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.Equal(expectedMatrixConfig, deserialized.MatrixConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -9830,6 +11916,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) @@ -9844,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, @@ -9883,6 +11979,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9893,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", }; @@ -9928,6 +12034,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); @@ -9937,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", }; @@ -9956,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, @@ -9979,6 +12105,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -10005,6 +12132,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); @@ -10014,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, @@ -10037,34 +12175,96 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() 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 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 ); @@ -10074,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 ); @@ -10097,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 ); @@ -10111,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 ); @@ -10154,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(); @@ -10193,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(); } @@ -10212,41 +12410,54 @@ 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(); } + + [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 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"), @@ -10257,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( @@ -10277,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 ); @@ -10294,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( @@ -10309,7 +12520,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10318,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 ); @@ -10349,96 +12750,595 @@ 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; - - 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 + 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() { - AdjustmentID = "adjustment_id", - - PlanPhaseOrder = null, + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, }; - - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new RemoveAdjustment + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() { - AdjustmentID = "adjustment_id", - - PlanPhaseOrder = null, + 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 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 ); @@ -10449,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(); } @@ -10476,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(); } @@ -10493,121 +13413,93 @@ 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(); } -} -public class ReplaceAdjustmentTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new ReplaceAdjustment + var model = new ThresholdTotalAmountLicenseAllocation { - 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, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - ReplaceAdjustmentAdjustment expectedAdjustment = new Models::NewPercentageDiscount() + ThresholdTotalAmountLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ThresholdTotalAmountConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + 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 ); @@ -10618,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(); @@ -10714,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(); @@ -10777,326 +13592,169 @@ 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(); } -} -public class ReplaceAdjustmentAdjustmentTest : TestBase -{ [Fact] - public void NewPercentageDiscountValidationWorks() + public void CopyConstructor_Works() { - ReplaceAdjustmentAdjustment value = 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, }; - value.Validate(); + + ThresholdTotalAmountConfig copied = new(model); + + Assert.Equal(model, copied); } +} +public class ConsumptionTableTest : TestBase +{ [Fact] - public void NewUsageDiscountValidationWorks() + public void FieldRoundtrip_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 expectedThreshold = "threshold"; + string expectedTotalAmount = "total_amount"; + + Assert.Equal(expectedThreshold, model.Threshold); + Assert.Equal(expectedTotalAmount, model.TotalAmount); } [Fact] - public void NewAmountDiscountValidationWorks() + public void SerializationRoundtrip_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 json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewMinimumValidationWorks() + public void FieldRoundtripThroughSerialization_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" }; + + 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 NewMaximumValidationWorks() + public void Validation_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" }; + + model.Validate(); } [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() + public void CopyConstructor_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, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var model = new ConsumptionTable { Threshold = "threshold", TotalAmount = "total_amount" }; - Assert.Equal(value, deserialized); + ConsumptionTable copied = new(model); + + Assert.Equal(model, copied); } +} +public class ThresholdTotalAmountConversionRateConfigTest : TestBase +{ [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() + public void UnitValidationWorks() { - 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); + ThresholdTotalAmountConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); } [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() + public void TieredValidationWorks() { - 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); + ThresholdTotalAmountConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); } [Fact] - public void NewMinimumSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - 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, - }; + 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 ); @@ -11105,30 +13763,25 @@ public void NewMinimumSerializationRoundtripWorks() } [Fact] - public void NewMaximumSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - 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, - }; + 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 ); @@ -11137,111 +13790,34 @@ public void NewMaximumSerializationRoundtripWorks() } } -public class ReplacePriceTest : TestBase +public class TieredPackageTest : 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", - 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", - }, - }; - - 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", - 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() @@ -11270,89 +13846,160 @@ public void FieldRoundtrip_Works() 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(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", - 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, - }, - 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 ); @@ -11363,113 +14010,186 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_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", - 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, - }, - 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 element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedReplacesPriceID = "replaces_price_id"; - Models::NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + ApiEnum expectedCadence = TieredPackageCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - ExpiresAtEndOfCadence = true, - Filters = + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_package"); + string expectedName = "Annual fee"; + TieredPackageConfig expectedTieredPackageConfig = 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", - PerUnitCostBasis = "per_unit_cost_basis", }; - long expectedPlanPhaseOrder = 0; - ReplacePricePrice expectedPrice = new Models::NewPlanUnitPrice() + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + 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", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], 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() @@ -11498,107 +14218,99 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedPrice, deserialized.Price); + model.Validate(); } [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_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 = - [ - 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() + ], + Name = "Annual fee", + TieredPackageConfig = 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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 OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new ReplacePrice { ReplacesPriceID = "replaces_price_id" }; - - 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(); } @@ -11606,106 +14318,147 @@ 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 - { - ReplacesPriceID = "replaces_price_id", - - AllocationPrice = null, - PlanPhaseOrder = null, - Price = null, - }; - - model.Validate(); - } -} - -public class ReplacePricePriceTest : TestBase -{ - [Fact] - public void NewPlanUnitValidationWorks() - { - ReplacePricePrice value = new Models::NewPlanUnitPrice() + var model = new TieredPackage { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = TieredPackageCadence.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() + TieredPackageConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanTieredValidationWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanTieredPrice() + var model = new TieredPackage { - Cadence = Models::NewPlanTieredPriceCadence.Annual, + Cadence = TieredPackageCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredConfig = new() + TieredPackageConfig = new() { + PackageSize = "package_size", Tiers = [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], - Prorated = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -11735,312 +14488,527 @@ public void NewPlanTieredValidationWorks() 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 NewPlanBulkValidationWorks() + public void InvalidEnumValidationThrows_Works() { - ReplacePricePrice 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + 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 BulkWithFiltersValidationWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - ReplacePricePrice value = 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", - }; - value.Validate(); + 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 NewPlanPackageValidationWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanPackagePrice() + var model = new TieredPackageLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - value.Validate(); + + 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 NewPlanMatrixValidationWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixPrice() + var model = new TieredPackageLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - value.Validate(); + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewPlanThresholdTotalAmountValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() + var model = new TieredPackageLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + 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 NewPlanTieredPackageValidationWorks() + public void TieredValidationWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() + TieredPackageConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( [ - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), }; value.Validate(); } [Fact] - public void NewPlanTieredWithMinimumValidationWorks() + public void UnitSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() + TieredPackageConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + 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", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", TieredWithMinimumConfig = new() { @@ -12090,30 +15058,147 @@ public void NewPlanTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + 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 NewPlanGroupedTieredValidationWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPrice() + var model = new TieredWithMinimum { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = TieredWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredWithMinimumConfig = new() { - GroupingKey = "x", Tiers = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_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, }, - ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12142,40 +15227,56 @@ public void NewPlanGroupedTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewPlanTieredPackageWithMinimumValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() + var model = new TieredWithMinimum { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + Cadence = TieredWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredPackageWithMinimumConfig = new() + TieredWithMinimumConfig = new() { - PackageSize = 0, Tiers = [ new() { MinimumAmount = "minimum_amount", - PerUnit = "per_unit", TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, new() { MinimumAmount = "minimum_amount", - PerUnit = "per_unit", TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ], + HideZeroAmountTiers = true, + Prorate = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12205,26 +15306,156 @@ public void NewPlanTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + 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 NewPlanPackageWithAllocationValidationWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() + var model = new TieredWithMinimum { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + Cadence = TieredWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - PackageWithAllocationConfig = new() + TieredWithMinimumConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + 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, @@ -12254,210 +15485,303 @@ public void NewPlanPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanUnitWithPercentValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanUnitWithPercentPrice() + var model = new TieredWithMinimum { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + Cadence = TieredWithMinimumCadence.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", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + TieredWithMinimumConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", }; - value.Validate(); + + 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 NewPlanMatrixWithAllocationValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() + var model = new TieredWithMinimum { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + Cadence = TieredWithMinimumCadence.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, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + TieredWithMinimumConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", }; - value.Validate(); + + model.Validate(); } [Fact] - public void TieredWithProrationValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - ReplacePricePrice value = new ReplacePricePriceTieredWithProration() + var model = new TieredWithMinimum { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = TieredWithMinimumCadence.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() + TieredWithMinimumConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - value.Validate(); + + 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 NewPlanUnitWithProrationValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - ReplacePricePrice value = new Models::NewPlanUnitWithProrationPrice() + var model = new TieredWithMinimum { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = TieredWithMinimumCadence.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", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + TieredWithMinimumConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanGroupedAllocationValidationWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() + var model = new TieredWithMinimum { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + Cadence = TieredWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, + 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() @@ -12486,574 +15810,746 @@ public void NewPlanGroupedAllocationValidationWorks() 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 NewPlanBulkWithProrationValidationWorks() + public void InvalidEnumValidationThrows_Works() { - ReplacePricePrice 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"), - }, + 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", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - value.Validate(); + + 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 NewPlanGroupedWithProratedMinimumValidationWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() + var model = new TieredWithMinimumLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - value.Validate(); + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewPlanGroupedWithMeteredMinimumValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + var model = new TieredWithMinimumLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - value.Validate(); + + 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 GroupedWithMinMaxThresholdsValidationWorks() + public void Validation_Works() { - ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() + var model = new TieredWithMinimumLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanMatrixWithDisplayNameValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() + var model = new TieredWithMinimumLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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(); + + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void NewPlanGroupedTieredPackageValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() + var model = new TieredWithMinimumLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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(); + + model.Validate(); } [Fact] - public void NewPlanMaxGroupTieredPackageValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() + var model = new TieredWithMinimumLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + + WriteOffOverage = null, }; - value.Validate(); + + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void NewPlanScalableMatrixWithUnitPricingValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + var model = new TieredWithMinimumLicenseAllocation { - 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", - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + + WriteOffOverage = null, }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanScalableMatrixWithTieredPricingValidationWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + var model = new TieredWithMinimumLicenseAllocation { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - value.Validate(); + + TieredWithMinimumLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); } +} +public class TieredWithMinimumConfigTest : TestBase +{ [Fact] - public void NewPlanCumulativeGroupedBulkValidationWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() + var model = new TieredWithMinimumConfig { - 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() + 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() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + new() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, - Currency = "currency", - DimensionalPriceConfiguration = new() + ]; + 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() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ]; + 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 CumulativeGroupedAllocationValidationWorks() + public void TieredValidationWorks() { - ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() + TieredWithMinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + 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() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + 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, @@ -13083,20 +16579,124 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + 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 MinimumValidationWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new ReplacePricePriceMinimum() + var model = new GroupedTiered { - Cadence = ReplacePricePriceMinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13126,21 +16726,45 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewPlanMinimumCompositeValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() + var model = new GroupedTiered { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, + 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", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13170,68 +16794,134 @@ public void NewPlanMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); - } - [Fact] - public void PercentValidationWorks() - { - ReplacePricePrice value = new ReplacePricePricePercent() + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedCadence = GroupedTieredCadence.Annual; + GroupedTieredConfig expectedGroupedTieredConfig = new() { - Cadence = ReplacePricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = 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() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + ]; + 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"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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 expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }; - value.Validate(); + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = 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 EventOutputValidationWorks() + public void Validation_Works() { - ReplacePricePrice value = new ReplacePricePriceEventOutput() + var model = new GroupedTiered { - Cadence = ReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = GroupedTieredCadence.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", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13261,190 +16951,247 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewPlanUnitSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanUnitPrice() + var model = new GroupedTiered { - 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() + Cadence = GroupedTieredCadence.Annual, + GroupedTieredConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.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 NewPlanTieredSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - ReplacePricePrice value = new Models::NewPlanTieredPrice() + var model = new GroupedTiered { - Cadence = Models::NewPlanTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() + Cadence = GroupedTieredCadence.Annual, + GroupedTieredConfig = new() { + GroupingKey = "x", Tiers = [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], - Prorated = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanBulkSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - ReplacePricePrice value = new Models::NewPlanBulkPrice() + var model = new GroupedTiered { - 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() + Cadence = GroupedTieredCadence.Annual, + GroupedTieredConfig = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + 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() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + GroupingKey = "x", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() + var model = new GroupedTiered { - BulkWithFiltersConfig = new() + Cadence = GroupedTieredCadence.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 = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13474,12 +17221,60 @@ public void BulkWithFiltersSerializationRoundtripWorks() 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, + + 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 ); @@ -13487,70 +17282,486 @@ public void BulkWithFiltersSerializationRoundtripWorks() } [Fact] - public void NewPlanPackageSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - ReplacePricePrice 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, + 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 NewPlanMatrixSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixPrice() + var model = new GroupedTieredConfig { - Cadence = Models::NewPlanMatrixPriceCadence.Annual, + 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", - MatrixConfig = new() + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + 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", + }, + ], }, - ModelType = Models::NewPlanMatrixPriceModelType.Matrix, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13579,35 +17790,147 @@ public void NewPlanMatrixSerializationRoundtripWorks() 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 + + 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(value, deserialized); + 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 NewPlanThresholdTotalAmountSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() + var model = new TieredPackageWithMinimum { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + Cadence = TieredPackageWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], 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, @@ -13637,34 +17960,54 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() 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, + + 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 NewPlanTieredPackageSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() + var model = new TieredPackageWithMinimum { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + Cadence = TieredPackageWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredPackageConfig = new() + TieredPackageWithMinimumConfig = new() { - PackageSize = "package_size", + 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", + }, ], }, BillableMetricID = "billable_metric_id", @@ -13695,46 +18038,160 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() 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( + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - Assert.Equal(value, 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 NewPlanTieredWithMinimumSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() + var model = new TieredPackageWithMinimum { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + Cadence = TieredPackageWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - TieredWithMinimumConfig = new() + TieredPackageWithMinimumConfig = new() { + PackageSize = 0, Tiers = [ new() { MinimumAmount = "minimum_amount", + PerUnit = "per_unit", TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", }, new() { MinimumAmount = "minimum_amount", + PerUnit = "per_unit", TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", }, ], - HideZeroAmountTiers = true, - Prorate = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13764,85 +18221,98 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() 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); + model.Validate(); } [Fact] - public void NewPlanGroupedTieredSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPrice() + var model = new TieredPackageWithMinimum { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = TieredPackageWithMinimumCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() { - GroupingKey = "x", + PackageSize = 0, Tiers = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, ], }, - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.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 NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() + var model = 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() { @@ -13863,167 +18333,186 @@ public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() }, ], }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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); + model.Validate(); } [Fact] - public void NewPlanPackageWithAllocationSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() + var model = new TieredPackageWithMinimum { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + Cadence = TieredPackageWithMinimumCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, + 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() + TieredPackageWithMinimumConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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", + }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.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 NewPlanUnitWithPercentSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - ReplacePricePrice value = new Models::NewPlanUnitWithPercentPrice() + var model = new TieredPackageWithMinimum { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + Cadence = TieredPackageWithMinimumCadence.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", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + TieredPackageWithMinimumConfig = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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", + }, + ], }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() + var model = new TieredPackageWithMinimum { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + Cadence = TieredPackageWithMinimumCadence.Annual, ItemID = "item_id", - MatrixWithAllocationConfig = new() + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + 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", + }, + ], }, - ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14052,189 +18541,623 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() 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); + 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 TieredWithProrationSerializationRoundtripWorks() + public void InvalidEnumValidationThrows_Works() { - ReplacePricePrice value = new ReplacePricePriceTieredWithProration() + 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 { - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + + 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); - Assert.Equal(value, 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 NewPlanUnitWithProrationSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanUnitWithProrationPrice() + var model = new TieredPackageWithMinimumLicenseAllocation { - 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() + 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() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + new() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", }, - Currency = "currency", - DimensionalPriceConfiguration = new() + ]; + + 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() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ]; + + 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", + }, + ], }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + + 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); - Assert.Equal(value, 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 NewPlanGroupedAllocationSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() + var model = new TieredPackageWithMinimumConfigTier { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() + 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() { - 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() + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + TieredPackageWithMinimumConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + 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"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + }; + 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() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + 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 PackageWithAllocationTest : TestBase +{ [Fact] - public void NewPlanBulkWithProrationSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() + var model = new PackageWithAllocation { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + Cadence = PackageWithAllocationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, + 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() @@ -14263,99 +19186,122 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() 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() - { - ReplacePricePrice 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() + ApiEnum expectedCadence = + PackageWithAllocationCadence.Annual; + string expectedItemID = "item_id"; + List expectedLicenseAllocations = + [ + new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + ]; + 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"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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 expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; - Assert.Equal(value, deserialized); + 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 NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + var model = new PackageWithAllocation { - 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" }, - ], - }, + Cadence = PackageWithAllocationCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + 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() @@ -14384,33 +19330,43 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() 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, + + 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 GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() + var model = new PackageWithAllocation { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + 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() @@ -14439,40 +19395,132 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() 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( + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - Assert.Equal(value, 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 NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() + var model = new PackageWithAllocation { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + Cadence = PackageWithAllocationCadence.Annual, ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14501,96 +19549,233 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() 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); + model.Validate(); } [Fact] - public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() + var model = new PackageWithAllocation { - Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() + Cadence = PackageWithAllocationCadence.Annual, + ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() { - GroupingKey = "x", + 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" }, - ], }, + }; + + 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", - ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + PackageWithAllocationConfig = new() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", }, - Currency = "currency", - DimensionalPriceConfiguration = new() + }; + + 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() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + + BillableMetricID = null, + BilledInAdvance = null, + 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() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() + var model = new PackageWithAllocation { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + Cadence = PackageWithAllocationCadence.Annual, ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + Name = "Annual fee", + PackageWithAllocationConfig = new() { - GroupingKey = "x", + Allocation = "allocation", + PackageAmount = "package_amount", 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() @@ -14619,175 +19804,426 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() 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); + PackageWithAllocation copied = new(model); + + Assert.Equal(model, copied); } +} - [Fact] - public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() - { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() +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 { - 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", - 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"), - }, + Amount = "amount", Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_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", + WriteOffOverage = true, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + + 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); - Assert.Equal(value, 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 NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + var model = new PackageWithAllocationLicenseAllocation { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + 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() { - 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() + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PackageWithAllocationConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + 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"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + }; + 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() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + 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 UnitWithPercentTest : TestBase +{ [Fact] - public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() + var model = new UnitWithPercent { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }, + Cadence = UnitWithPercentCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + 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() @@ -14816,33 +20252,113 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() 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); + 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 CumulativeGroupedAllocationSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() + var model = new UnitWithPercent { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + 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() @@ -14871,27 +20387,38 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() 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, + + 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 MinimumSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new ReplacePricePriceMinimum() + var model = new UnitWithPercent { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = UnitWithPercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + 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() @@ -14920,424 +20447,36 @@ public void MinimumSerializationRoundtripWorks() 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( + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - 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; + ApiEnum expectedCadence = UnitWithPercentCadence.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() + List expectedLicenseAllocations = + [ + new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }, - 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() + ]; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit_with_percent"); + string expectedName = "Annual fee"; + UnitWithPercentConfig expectedUnitWithPercentConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Percent = "percent", + UnitAmount = "unit_amount", }; - 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() @@ -15346,7 +20485,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + UnitWithPercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -15367,14 +20506,20 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedUnitWithPercentConfig, deserialized.UnitWithPercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -15389,6 +20534,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) @@ -15403,20 +20549,21 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new UnitWithPercent { - 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, + 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() @@ -15445,6 +20592,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15455,20 +20603,21 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new UnitWithPercent { - 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, + 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); @@ -15493,6 +20642,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); @@ -15502,20 +20653,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new UnitWithPercent { - 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, + 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(); @@ -15524,20 +20676,21 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new UnitWithPercent { - 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, + 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, @@ -15550,6 +20703,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -15576,6 +20730,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); @@ -15585,20 +20741,21 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new ReplacePricePriceBulkWithFilters + var model = new UnitWithPercent { - 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, + 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, @@ -15611,70 +20768,173 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } -} -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + var model = new UnitWithPercent { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + Cadence = UnitWithPercentCadence.Annual, + ItemID = "item_id", + LicenseAllocations = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, ], - }; - - 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" }, - ]; + 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", + }; - 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++) + 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 { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + var model = new UnitWithPercentLicenseAllocation { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + 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); } @@ -15682,170 +20942,136 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + var model = new UnitWithPercentLicenseAllocation { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + 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); - 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" }, - ]; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - 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(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + var model = new UnitWithPercentLicenseAllocation { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; model.Validate(); } -} -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + var model = new UnitWithPercentLicenseAllocation { - PropertyKey = "x", - PropertyValue = "x", + Amount = "amount", + Currency = "currency", }; - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void SerializationRoundtrip_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + var model = new UnitWithPercentLicenseAllocation { - PropertyKey = "x", - PropertyValue = "x", + Amount = "amount", + Currency = "currency", }; - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + model.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + var model = new UnitWithPercentLicenseAllocation { - PropertyKey = "x", - PropertyValue = "x", + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, }; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); + } - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new UnitWithPercentLicenseAllocation + { + Amount = "amount", + Currency = "currency", - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + WriteOffOverage = null, + }; + + model.Validate(); } [Fact] - public void Validation_Works() + public void CopyConstructor_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + var model = new UnitWithPercentLicenseAllocation { - PropertyKey = "x", - PropertyValue = "x", + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, }; - model.Validate(); + UnitWithPercentLicenseAllocation copied = new(model); + + Assert.Equal(model, copied); } } -public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase +public class UnitWithPercentConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; + var model = new UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; + string expectedPercent = "percent"; string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + Assert.Equal(expectedPercent, model.Percent); 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", - }; + var model = new UnitWithPercentConfig { Percent = "percent", 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); } @@ -15853,248 +21079,76667 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", - }; + var model = new UnitWithPercentConfig { Percent = "percent", 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 expectedPercent = "percent"; string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + Assert.Equal(expectedPercent, deserialized.Percent); 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", - }; + var model = new UnitWithPercentConfig { Percent = "percent", UnitAmount = "unit_amount" }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + 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() { - UnitAmount = "unit_amount", + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; + value.Validate(); + } - Assert.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + [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 OptionalNullablePropertiesUnsetValidation_Works() + public void UnitSerializationRoundtripWorks() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + UnitWithPercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - UnitAmount = "unit_amount", + 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 OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void TieredSerializationRoundtripWorks() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + UnitWithPercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - UnitAmount = "unit_amount", - - TierLowerBound = null, + 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.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + Assert.Equal(value, deserialized); } +} +public class MatrixWithAllocationTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + var model = new MatrixWithAllocation { - UnitAmount = "unit_amount", + 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", + }; - TierLowerBound = null, + 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"; - model.Validate(); + 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); } -} -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() + { + 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] + public void NewPlanUnitValidationWorks() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice value = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanPackageValidationWorks() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice value = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanUnitWithProrationValidationWorks() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice value = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanMatrixWithDisplayNameValidationWorks() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + 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, + }, + LicenseTypeID = "license_type_id", + 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, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + 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() + { + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void EventOutputValidationWorks() + { + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); + } + + [Fact] + public void NewPlanUnitSerializationRoundtripWorks() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice value = 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, + }, + 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice value = 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, + }, + 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice value = 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, + }, + 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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() + { + ReplacePricePrice 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 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) + public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() { - // 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); + ReplacePricePrice 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 InvalidEnumSerializationRoundtrip_Works() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - 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); + 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, + }, + 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 ReplacePricePriceBulkWithFiltersConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void NewPlanMinimumCompositeSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() + 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"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() + }, + Currency = "currency", + DimensionalPriceConfiguration = new() { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = 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 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, + }, + 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 - ); + 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, + }, + 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 - ); + 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() @@ -16123,17 +97768,25 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - ReplacePricePriceTieredWithProrationCadence.Annual; + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = + ReplacePricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -16142,7 +97795,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16163,14 +97816,15 @@ public void FieldRoundtrip_Works() 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(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -16182,6 +97836,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) @@ -16196,14 +97851,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() @@ -16232,12 +97893,13 @@ public void SerializationRoundtrip_Works() 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 ); @@ -16248,14 +97910,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() @@ -16284,24 +97952,32 @@ public void FieldRoundtripThroughSerialization_Works() 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); - ApiEnum expectedCadence = - ReplacePricePriceTieredWithProrationCadence.Annual; + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = + ReplacePricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -16310,7 +97986,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16331,14 +98007,15 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -16353,6 +98030,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) @@ -16367,14 +98045,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() @@ -16403,6 +98087,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16413,14 +98098,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); @@ -16445,6 +98136,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); @@ -16454,14 +98147,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceTieredWithProration + var model = new ReplacePricePriceBulkWithFilters { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -16470,14 +98169,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, @@ -16490,6 +98195,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -16516,6 +98222,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); @@ -16525,14 +98233,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_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, @@ -16545,91 +98259,100 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } -} - -public class ReplacePricePriceTieredWithProrationCadenceTest : 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) - { - // 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(ReplacePricePriceTieredWithProrationCadence.Annual)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Monthly)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Quarterly)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.OneTime)] - [InlineData(ReplacePricePriceTieredWithProrationCadence.Custom)] - public void SerializationRoundtrip_Works(ReplacePricePriceTieredWithProrationCadence rawValue) + public void CopyConstructor_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); - } + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; - [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); + ReplacePricePriceBulkWithFilters copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } -public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; - List expectedTiers = + List expectedFilters = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ]; + Assert.Equal(expectedFilters.Count, model.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], model.Filters[i]); + } Assert.Equal(expectedTiers.Count, model.Tiers.Count); for (int i = 0; i < expectedTiers.Count; i++) { @@ -16640,14 +98363,19 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -16658,24 +98386,39 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - List expectedTiers = + List expectedFilters = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ]; + Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], deserialized.Filters[i]); + } Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); for (int i = 0; i < expectedTiers.Count; i++) { @@ -16686,45 +98429,156 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; model.Validate(); } + + [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 ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + 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(); + } + + [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 +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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 ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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 ); @@ -16735,46 +98589,172 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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 expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); } [Fact] public void Validation_Works() { - var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + 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(); } + + [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 ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase +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() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16786,7 +98766,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16807,7 +98787,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16815,7 +98795,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16826,7 +98806,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16843,7 +98823,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16852,23 +98832,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() @@ -16897,25 +98873,18 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + ApiEnum expectedCadence = + ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -16924,7 +98893,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16945,17 +98914,15 @@ public void FieldRoundtrip_Works() 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(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -16967,6 +98934,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) @@ -16981,18 +98949,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() @@ -17021,12 +98985,13 @@ public void SerializationRoundtrip_Works() 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 ); @@ -17037,18 +99002,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() @@ -17077,32 +99038,25 @@ public void FieldRoundtripThroughSerialization_Works() 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); - ApiEnum expectedCadence = - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + ApiEnum expectedCadence = + ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -17111,7 +99065,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17132,17 +99086,15 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -17157,6 +99109,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) @@ -17171,18 +99124,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() @@ -17211,6 +99160,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17221,18 +99171,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); @@ -17257,6 +99203,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); @@ -17266,18 +99214,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceGroupedWithMinMaxThresholds + var model = new ReplacePricePriceTieredWithProration { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -17286,18 +99230,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, @@ -17310,6 +99250,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17336,6 +99277,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); @@ -17345,18 +99288,14 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_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, @@ -17369,27 +99308,77 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePricePriceTieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase +public class ReplacePricePriceTieredWithProrationCadenceTest : TestBase { [Theory] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] - public void Validation_Works(ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue) + [InlineData(ReplacePricePriceTieredWithProrationCadence.Annual)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Monthly)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Quarterly)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.OneTime)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Custom)] + public void Validation_Works(ReplacePricePriceTieredWithProrationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -17397,7 +99386,7 @@ public void Validation_Works(ReplacePricePriceGroupedWithMinMaxThresholdsCadence public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -17405,22 +99394,20 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] - public void SerializationRoundtrip_Works( - ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue - ) + [InlineData(ReplacePricePriceTieredWithProrationCadence.Annual)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Monthly)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Quarterly)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.OneTime)] + [InlineData(ReplacePricePriceTieredWithProrationCadence.Custom)] + public void SerializationRoundtrip_Works(ReplacePricePriceTieredWithProrationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -17430,58 +99417,50 @@ ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest - : TestBase +public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } } [Fact] public void SerializationRoundtrip_Works() { - var model = - new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -17492,56 +99471,150 @@ 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(); } + + [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 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(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17553,7 +99626,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17574,7 +99647,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17582,7 +99655,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17593,7 +99666,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17610,7 +99683,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17619,20 +99692,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", @@ -17664,23 +99737,24 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + ApiEnum expectedCadence = + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -17691,7 +99765,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17712,13 +99786,14 @@ public void FieldRoundtrip_Works() 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 + expectedGroupedWithMinMaxThresholdsConfig, + model.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); @@ -17734,6 +99809,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) @@ -17748,15 +99824,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", @@ -17788,12 +99864,13 @@ public void SerializationRoundtrip_Works() 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 ); @@ -17804,15 +99881,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", @@ -17844,30 +99921,31 @@ public void FieldRoundtripThroughSerialization_Works() 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); - ApiEnum expectedCadence = - ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + ApiEnum expectedCadence = + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -17878,7 +99956,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17899,13 +99977,14 @@ public void FieldRoundtripThroughSerialization_Works() 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 + expectedGroupedWithMinMaxThresholdsConfig, + deserialized.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); @@ -17924,6 +100003,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) @@ -17938,15 +100018,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", @@ -17978,6 +100058,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17988,15 +100069,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", @@ -18024,6 +100105,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,15 +100116,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceCumulativeGroupedAllocation + var model = new ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -18053,15 +100136,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", @@ -18077,6 +100160,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18103,6 +100187,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); @@ -18112,15 +100198,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", @@ -18136,27 +100222,81 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePricePriceGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase { [Theory] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] - public void Validation_Works(ReplacePricePriceCumulativeGroupedAllocationCadence rawValue) + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] + public void Validation_Works(ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } @@ -18164,7 +100304,7 @@ public void Validation_Works(ReplacePricePriceCumulativeGroupedAllocationCadence public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -18172,22 +100312,22 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] - [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] public void SerializationRoundtrip_Works( - ReplacePricePriceCumulativeGroupedAllocationCadence rawValue + ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -18197,58 +100337,58 @@ ReplacePricePriceCumulativeGroupedAllocationCadence rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest +public class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedMaximumCharge, model.MaximumCharge); + Assert.Equal(expectedMinimumCharge, model.MinimumCharge); + Assert.Equal(expectedPerUnitRate, model.PerUnitRate); } [Fact] public void SerializationRoundtrip_Works() { var model = - new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18260,55 +100400,74 @@ 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(); } + + [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 ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18320,7 +100479,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18341,7 +100500,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18349,7 +100508,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18360,7 +100519,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18377,7 +100536,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18386,16 +100545,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, @@ -18425,19 +100590,25 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - ReplacePricePriceMinimumCadence.Annual; + ApiEnum expectedCadence = + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -18447,7 +100618,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18468,12 +100639,16 @@ public void FieldRoundtrip_Works() 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(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -18487,6 +100662,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) @@ -18501,11 +100677,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, @@ -18535,12 +100717,13 @@ public void SerializationRoundtrip_Works() 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 ); @@ -18551,11 +100734,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, @@ -18585,26 +100774,32 @@ public void FieldRoundtripThroughSerialization_Works() 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); - ApiEnum expectedCadence = - ReplacePricePriceMinimumCadence.Annual; + ApiEnum expectedCadence = + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -18614,7 +100809,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18635,12 +100830,16 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -18657,6 +100856,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) @@ -18671,11 +100871,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, @@ -18705,6 +100911,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18715,11 +100922,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", }; @@ -18745,6 +100958,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); @@ -18754,11 +100969,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new ReplacePricePriceMinimum + var model = new ReplacePricePriceCumulativeGroupedAllocation { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -18768,11 +100989,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, @@ -18786,6 +101013,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18812,6 +101040,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); @@ -18821,11 +101051,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, @@ -18839,57 +101075,112 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePricePriceCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceMinimumCadenceTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase { [Theory] - [InlineData(ReplacePricePriceMinimumCadence.Annual)] - [InlineData(ReplacePricePriceMinimumCadence.SemiAnnual)] - [InlineData(ReplacePricePriceMinimumCadence.Monthly)] - [InlineData(ReplacePricePriceMinimumCadence.Quarterly)] - [InlineData(ReplacePricePriceMinimumCadence.OneTime)] - [InlineData(ReplacePricePriceMinimumCadence.Custom)] - public void Validation_Works(ReplacePricePriceMinimumCadence rawValue) + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + public void Validation_Works(ReplacePricePriceCumulativeGroupedAllocationCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); Assert.Throws(() => value.Validate()); } [Theory] - [InlineData(ReplacePricePriceMinimumCadence.Annual)] - [InlineData(ReplacePricePriceMinimumCadence.SemiAnnual)] - [InlineData(ReplacePricePriceMinimumCadence.Monthly)] - [InlineData(ReplacePricePriceMinimumCadence.Quarterly)] - [InlineData(ReplacePricePriceMinimumCadence.OneTime)] - [InlineData(ReplacePricePriceMinimumCadence.Custom)] - public void SerializationRoundtrip_Works(ReplacePricePriceMinimumCadence rawValue) + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works( + ReplacePricePriceCumulativeGroupedAllocationCadence rawValue + ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -18898,51 +101189,62 @@ public void SerializationRoundtrip_Works(ReplacePricePriceMinimumCadence rawValu [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceMinimumMinimumConfigTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -18950,91 +101252,75 @@ 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" }; + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void CopyConstructor_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", + var model = + new ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = new( + model + ); - model.Validate(); + Assert.Equal(model, copied); } } -public class ReplacePricePriceMinimumConversionRateConfigTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19046,7 +101332,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19067,17 +101353,18 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -19085,7 +101372,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19101,10 +101388,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); } @@ -19149,6 +101437,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19188,6 +101477,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"; @@ -19207,6 +101497,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) @@ -19255,6 +101546,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19305,6 +101597,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19351,6 +101644,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"; @@ -19373,6 +101667,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) @@ -19421,6 +101716,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19461,6 +101757,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); @@ -19502,6 +101800,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19528,6 +101827,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); @@ -19555,12 +101856,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePricePricePercent copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePricePercentCadenceTest : TestBase @@ -19677,6 +102026,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 @@ -19804,6 +102163,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19848,6 +102208,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"; @@ -19867,6 +102228,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) @@ -19920,6 +102282,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19975,6 +102338,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20026,6 +102390,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"; @@ -20048,6 +102413,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) @@ -20101,6 +102467,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20146,6 +102513,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); @@ -20197,6 +102566,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20223,6 +102593,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); @@ -20255,12 +102627,65 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + ReplacePricePriceEventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceEventOutputCadenceTest : TestBase @@ -20455,6 +102880,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/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/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..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, @@ -1031,6 +1073,181 @@ 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + ], + 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..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"), @@ -5083,131 +5167,989 @@ 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, + }, + ], + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + 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", @@ -5220,196 +6162,656 @@ public void FieldRoundtrip_Works() 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 = + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + 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::CompositePriceFilterField.PriceID, - Operator = Models::CompositePriceFilterOperator.Includes, + Field = Models::MonetaryUsageDiscountAdjustmentFilterField.PriceID, + Operator = + Models::MonetaryUsageDiscountAdjustmentFilterOperator.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() + 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() { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Models::Field.PriceID, - Operator = Models::Operator.Includes, - Values = ["string"], - }, - ], + 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", - 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() + CustomExpiration = 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", + DurationUnit = Models::CustomExpirationDurationUnit.Day, }, + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", 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 = + 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", + 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"), }, - 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() + BillingAddress = new() { City = "city", Country = "country", @@ -5418,431 +6820,341 @@ public void FieldRoundtrip_Works() 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() + 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() { - DiscountType = Models::PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = Models::PercentageDiscountFilterField.PriceID, - Operator = Models::PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", + Country = Models::Country.Ad, + Type = Models::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 = - 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() + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + new Models::PercentageDiscount() { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::DurationUnit.Day, - }, - BillingMode = Models::BillingMode.InAdvance, - Cadence = Models::UnitCadence.OneTime, - CompositePriceFilters = + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, - 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 { @@ -6017,6 +7329,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6084,6 +7397,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"), @@ -6181,372 +7500,342 @@ 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() + { + 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() { - Enabled = true, - NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - NumAttempts = 0, - PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + DiscountType = Models::PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = Models::PercentageDiscountFilterField.PriceID, + Operator = Models::PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", }, - BillingAddress = 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() { - 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", + 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", - 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 = + 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() - { - 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() + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() + 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::DurationUnit.Day, + DurationUnit = Models::CustomExpirationDurationUnit.Day, }, - BillingMode = Models::BillingMode.InAdvance, - Cadence = Models::UnitCadence.OneTime, - CompositePriceFilters = + Filters = + [ + new() + { + Field = Models::Field.PriceID, + Operator = Models::Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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::CompositePriceFilterField.PriceID, - Operator = Models::CompositePriceFilterOperator.Includes, + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.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", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", 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 = + 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", + UsageCustomerIds = ["string"], }, - MinimumAmount = "minimum_amount", - PaidAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PaymentAttempts = + ]; + Models::Maximum expectedMaximum = new() + { + AppliesToPriceIds = ["string"], + Filters = [ 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, + Field = Models::MaximumFilterField.PriceID, + Operator = Models::MaximumFilterOperator.Includes, + Values = ["string"], }, ], - 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, + MaximumAmount = "maximum_amount", }; - - 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() + string expectedMaximumAmount = "maximum_amount"; + string expectedMemo = "memo"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + Models::Minimum expectedMinimum = new() { - Enabled = true, - NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - NumAttempts = 0, - PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + AppliesToPriceIds = ["string"], + Filters = + [ + new() + { + Field = Models::MinimumFilterField.PriceID, + Operator = Models::MinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + MinimumAmount = "minimum_amount", }; - Models::Address expectedBillingAddress = new() + 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", @@ -6555,404 +7844,442 @@ public void FieldRoundtripThroughSerialization_Works() 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() + 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); + } + + [Fact] + public void Validation_Works() + { + var model = new Models::CreatedInvoice { ID = "id", - ExternalCustomerID = "external_customer_id", - }; - List expectedCustomerBalanceTransactions = - [ - new() + AmountDue = "8.00", + AutoCollection = 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, + Enabled = true, + NextAttemptAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + NumAttempts = 0, + PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }, - ]; - Models::CustomerTaxID expectedCustomerTaxID = new() - { - Country = Models::Country.Ad, - Type = Models::CustomerTaxIDType.AdNrt, - Value = "value", - }; - JsonElement expectedDiscount = JsonSerializer.Deserialize("{}"); - List expectedDiscounts = - [ - new Models::PercentageDiscount() + BillingAddress = 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", + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", }, - ]; - 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() + 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() { - 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() + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Discount = JsonSerializer.Deserialize("{}"), + Discounts = + [ + new Models::PercentageDiscount() { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::DurationUnit.Day, - }, - BillingMode = Models::BillingMode.InAdvance, - Cadence = Models::UnitCadence.OneTime, - CompositePriceFilters = + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }, - 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, 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); + model.Validate(); } [Fact] - public void Validation_Works() + public void CopyConstructor_Works() { var model = new Models::CreatedInvoice { @@ -7127,6 +8454,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7194,6 +8522,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"), @@ -7291,7 +8625,9 @@ public void Validation_Works() WillAutoIssue = true, }; - model.Validate(); + Models::CreatedInvoice copied = new(model); + + Assert.Equal(model, copied); } } @@ -7385,6 +8721,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 @@ -7482,7 +8834,24 @@ public void FieldRoundtripThroughSerialization_Works() } [Fact] - public void Validation_Works() + public void Validation_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"), + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() { var model = new Models::CreditNote { @@ -7495,7 +8864,9 @@ public void Validation_Works() VoidedAt = DateTimeOffset.Parse("2022-05-01T07:01:31+00:00"), }; - model.Validate(); + Models::CreditNote copied = new(model); + + Assert.Equal(model, copied); } } @@ -7633,6 +9004,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 @@ -7914,6 +9307,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7981,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"), @@ -8088,6 +9488,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8155,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"); @@ -8304,6 +9711,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8371,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"), @@ -8494,6 +9908,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8561,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"), @@ -8675,6 +10096,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8742,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"); @@ -8891,6 +10319,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8958,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"), @@ -8989,6 +10424,199 @@ 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + 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 +11151,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/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..9d0f61f05 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 @@ -174,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 @@ -224,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/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/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/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/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/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/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/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/CreditBlocks/CreditBlockRetrieveResponseTest.cs b/src/Orb.Tests/Models/CreditBlocks/CreditBlockRetrieveResponseTest.cs index 260a03ebd..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,12 +194,42 @@ public void Validation_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }; 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, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + Status = Status.Active, + }; + + CreditBlockRetrieveResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class FilterTest : TestBase @@ -263,6 +312,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 b4d7d46ad..fed689221 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 @@ -271,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/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/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/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/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..3d62e169b 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 @@ -449,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)] @@ -579,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.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/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/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/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/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/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/CostListByExternalIDResponseTest.cs b/src/Orb.Tests/Models/Customers/Costs/CostListByExternalIDResponseTest.cs index 173628e43..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", @@ -875,4 +917,157 @@ 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"], + }, + ], + 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", + }, + }, + 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/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/Costs/CostListResponseTest.cs b/src/Orb.Tests/Models/Customers/Costs/CostListResponseTest.cs index dc2b23106..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", @@ -875,4 +917,157 @@ 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"], + }, + ], + 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", + }, + }, + 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..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, }, @@ -219,4 +225,40 @@ 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, + Metadata = new Dictionary() { { "foo", "string" } }, + 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/CreditListByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDParamsTest.cs index 5f8fe537f..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,9 +161,30 @@ 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 ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CreditListByExternalIDParams + { + 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, + }; + + CreditListByExternalIDParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/CreditListByExternalIDResponseTest.cs index 93d1e1994..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,12 +196,42 @@ public void Validation_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = CreditListByExternalIDResponseStatus.Active, }; 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, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + Status = CreditListByExternalIDResponseStatus.Active, + }; + + CreditListByExternalIDResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class CreditListByExternalIDResponseFilterTest : TestBase @@ -275,6 +324,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..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, }, @@ -219,4 +225,40 @@ 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, + Metadata = new Dictionary() { { "foo", "string" } }, + 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/CreditListParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/CreditListParamsTest.cs index b00d7ced7..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,9 +161,30 @@ 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 ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new CreditListParams + { + 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, + }; + + CreditListParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/Credits/CreditListResponseTest.cs b/src/Orb.Tests/Models/Customers/Credits/CreditListResponseTest.cs index f27809e6f..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,12 +194,42 @@ public void Validation_Works() }, ], MaximumInitialBalance = 0, + Metadata = new Dictionary() { { "foo", "string" } }, PerUnitCostBasis = "per_unit_cost_basis", Status = Status.Active, }; 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, + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", + Status = Status.Active, + }; + + CreditListResponse copied = new(model); + + Assert.Equal(model, copied); + } } public class FilterTest : TestBase @@ -263,6 +312,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..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"), @@ -2486,6 +2528,394 @@ 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + 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 52d83f735..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, @@ -131,6 +134,50 @@ 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", + MarkAsPaid = true, + 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 @@ -162,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, @@ -261,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, @@ -392,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, @@ -422,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, @@ -479,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, @@ -523,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, @@ -561,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, @@ -618,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, @@ -714,6 +769,46 @@ 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", + MarkAsPaid = true, + 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 @@ -814,6 +909,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 @@ -945,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, @@ -956,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; @@ -964,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); @@ -978,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, @@ -1002,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, @@ -1021,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; @@ -1029,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); @@ -1043,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, @@ -1064,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")); } @@ -1097,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")); } @@ -1117,6 +1240,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() NetTerms = 0, // Null should be interpreted as omitted for these properties + MarkAsPaid = null, RequireSuccessfulPayment = null, }; @@ -1129,6 +1253,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() var model = new LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, }; @@ -1150,6 +1275,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() var model = new LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, }; @@ -1162,6 +1288,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() var model = new LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, CustomDueDate = null, @@ -1189,6 +1316,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() var model = new LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, CustomDueDate = null, @@ -1200,6 +1328,26 @@ 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", + MarkAsPaid = true, + Memo = "memo", + NetTerms = 0, + RequireSuccessfulPayment = true, + }; + + LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings copied = new(model); + + Assert.Equal(model, copied); + } } public class LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettingsCustomDueDateTest @@ -1464,6 +1612,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 @@ -1676,6 +1840,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 @@ -1872,6 +2055,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 @@ -2108,4 +2309,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/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/LedgerCreateEntryParamsTest.cs b/src/Orb.Tests/Models/Customers/Credits/Ledger/LedgerCreateEntryParamsTest.cs index a21e4975d..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, @@ -125,6 +128,49 @@ 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", + MarkAsPaid = true, + 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 @@ -154,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, @@ -247,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, @@ -373,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, @@ -402,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, @@ -458,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, @@ -500,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, @@ -536,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, @@ -592,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, @@ -688,6 +742,45 @@ 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", + MarkAsPaid = true, + 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 @@ -776,6 +869,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 @@ -903,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, @@ -912,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; @@ -920,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); @@ -934,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, @@ -957,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, @@ -973,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; @@ -981,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); @@ -995,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, @@ -1016,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")); } @@ -1049,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")); } @@ -1069,6 +1190,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() NetTerms = 0, // Null should be interpreted as omitted for these properties + MarkAsPaid = null, RequireSuccessfulPayment = null, }; @@ -1081,6 +1203,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() var model = new Ledger::InvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, }; @@ -1102,6 +1225,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() var model = new Ledger::InvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, }; @@ -1114,6 +1238,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() var model = new Ledger::InvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, CustomDueDate = null, @@ -1141,6 +1266,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() var model = new Ledger::InvoiceSettings { AutoCollection = true, + MarkAsPaid = true, RequireSuccessfulPayment = true, CustomDueDate = null, @@ -1152,6 +1278,26 @@ 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", + MarkAsPaid = true, + Memo = "memo", + NetTerms = 0, + RequireSuccessfulPayment = true, + }; + + Ledger::InvoiceSettings copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomDueDateTest : TestBase @@ -1400,6 +1546,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 @@ -1604,6 +1766,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 @@ -1790,6 +1971,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 @@ -2018,4 +2217,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/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 f72ba1727..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"), @@ -2485,4 +2527,427 @@ 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + 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/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/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 081def1fe..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"), @@ -2485,4 +2527,427 @@ 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + 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/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/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/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 dbd7568a7..c2d410fce 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 @@ -350,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 9fa88d82d..d91ba60ad 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 @@ -347,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/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/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/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/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/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/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 578e36389..9ebd2ead7 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 @@ -465,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 @@ -605,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 @@ -977,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 @@ -1075,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 @@ -1173,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/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/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/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/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 f30346cab..292dfd2ee 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 @@ -493,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 @@ -657,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 @@ -1117,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 @@ -1239,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 @@ -1361,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 7df9fd352..f92ad46c0 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 @@ -486,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 @@ -650,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 @@ -1071,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 @@ -1191,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 @@ -1311,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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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/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 09865dfd0..f818a2823 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 @@ -411,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/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/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/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/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/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/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/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/InvoiceLineItems/InvoiceLineItemCreateResponseTest.cs b/src/Orb.Tests/Models/InvoiceLineItems/InvoiceLineItemCreateResponseTest.cs index e35616bc9..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"), @@ -1169,6 +1211,199 @@ 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + 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..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"), @@ -2196,6 +2238,356 @@ 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"], + }, + ], + 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", + }, + }, + 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 @@ -2286,7 +2678,23 @@ public void Validation_Works() PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; - model.Validate(); + 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); } } @@ -2400,6 +2808,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 +2967,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 @@ -2806,6 +3255,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2873,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"), @@ -2975,6 +3431,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3038,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"); @@ -3180,6 +3643,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3247,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"), @@ -3363,6 +3833,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3430,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"), @@ -3539,6 +4016,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3602,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"); @@ -3744,6 +4228,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3811,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"), @@ -3842,6 +4333,192 @@ 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"], + }, + ], + 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", + }, + }, + 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 +5051,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 30ca312ff..639f8a732 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,25 +23,26 @@ 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", UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }, ], + AutoCollection = true, 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,37 +58,38 @@ 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", UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }, ]; + bool expectedAutoCollection = true; 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" } }; @@ -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); @@ -121,7 +124,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,25 +134,26 @@ 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", UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }, ], + AutoCollection = true, 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 +173,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,25 +183,26 @@ 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", UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, }, ], + AutoCollection = true, 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 +225,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 +235,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", @@ -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); @@ -259,7 +266,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 +276,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", @@ -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); @@ -306,7 +316,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 +326,7 @@ public void Url_Works() { EndDate = "2023-09-22", ItemID = "4khy3nwzktxv7", - ModelType = Invoices::ModelType.Unit, + ModelType = ModelType.Unit, Name = "Line Item Name", Quantity = 1, StartDate = "2023-09-22", @@ -329,6 +339,57 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/invoices"), url); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoiceCreateParams + { + Currency = "USD", + InvoiceDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + LineItems = + [ + new() + { + EndDate = "2023-09-22", + ItemID = "4khy3nwzktxv7", + ModelType = ModelType.Unit, + Name = "Line Item Name", + Quantity = 1, + StartDate = "2023-09-22", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + }, + ], + AutoCollection = true, + CustomerID = "4khy3nwzktxv7", + Discount = new Models::PercentageDiscount() + { + DiscountType = Models::PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = Models::PercentageDiscountFilterField.PriceID, + Operator = Models::PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + DueDate = "2023-09-22", + ExternalCustomerID = "external-customer-id", + Memo = "An optional memo for my invoice.", + Metadata = new Dictionary() { { "foo", "string" } }, + NetTerms = 0, + WillAutoIssue = false, + }; + + InvoiceCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class LineItemTest : TestBase @@ -336,11 +397,11 @@ public class LineItemTest : TestBase [Fact] public void FieldRoundtrip_Works() { - var model = new Invoices::LineItem + var model = new LineItem { EndDate = "2023-09-22", ItemID = "4khy3nwzktxv7", - ModelType = Invoices::ModelType.Unit, + ModelType = ModelType.Unit, Name = "Line Item Name", Quantity = 1, StartDate = "2023-09-22", @@ -349,11 +410,15 @@ public void FieldRoundtrip_Works() string expectedEndDate = "2023-09-22"; string expectedItemID = "4khy3nwzktxv7"; - ApiEnum expectedModelType = Invoices::ModelType.Unit; + ApiEnum expectedModelType = ModelType.Unit; string expectedName = "Line Item Name"; double expectedQuantity = 1; string expectedStartDate = "2023-09-22"; - UnitConfig expectedUnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; Assert.Equal(expectedEndDate, model.EndDate); Assert.Equal(expectedItemID, model.ItemID); @@ -367,11 +432,11 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Invoices::LineItem + var model = new LineItem { EndDate = "2023-09-22", ItemID = "4khy3nwzktxv7", - ModelType = Invoices::ModelType.Unit, + ModelType = ModelType.Unit, Name = "Line Item Name", Quantity = 1, StartDate = "2023-09-22", @@ -379,10 +444,7 @@ public void SerializationRoundtrip_Works() }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -390,11 +452,11 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Invoices::LineItem + var model = new LineItem { EndDate = "2023-09-22", ItemID = "4khy3nwzktxv7", - ModelType = Invoices::ModelType.Unit, + ModelType = ModelType.Unit, Name = "Line Item Name", Quantity = 1, StartDate = "2023-09-22", @@ -402,7 +464,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -410,11 +472,15 @@ public void FieldRoundtripThroughSerialization_Works() string expectedEndDate = "2023-09-22"; string expectedItemID = "4khy3nwzktxv7"; - ApiEnum expectedModelType = Invoices::ModelType.Unit; + ApiEnum expectedModelType = ModelType.Unit; string expectedName = "Line Item Name"; double expectedQuantity = 1; string expectedStartDate = "2023-09-22"; - UnitConfig expectedUnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }; + Models::UnitConfig expectedUnitConfig = new() + { + UnitAmount = "unit_amount", + Prorated = true, + }; Assert.Equal(expectedEndDate, deserialized.EndDate); Assert.Equal(expectedItemID, deserialized.ItemID); @@ -428,11 +494,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", @@ -441,23 +507,42 @@ 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 { [Theory] - [InlineData(Invoices::ModelType.Unit)] - public void Validation_Works(Invoices::ModelType rawValue) + [InlineData(ModelType.Unit)] + public void Validation_Works(ModelType rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -467,14 +552,14 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(Invoices::ModelType.Unit)] - public void SerializationRoundtrip_Works(Invoices::ModelType rawValue) + [InlineData(ModelType.Unit)] + public void SerializationRoundtrip_Works(ModelType rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -485,12 +570,12 @@ public void SerializationRoundtrip_Works(Invoices::ModelType rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -504,23 +589,23 @@ public class DueDateTest : TestBase [Fact] public void DateValidationWorks() { - Invoices::DueDate value = "2019-12-27"; + DueDate value = "2019-12-27"; value.Validate(); } [Fact] public void DateTimeValidationWorks() { - Invoices::DueDate value = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DueDate value = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); value.Validate(); } [Fact] public void DateSerializationRoundtripWorks() { - Invoices::DueDate value = "2019-12-27"; + DueDate value = "2019-12-27"; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -531,9 +616,9 @@ public void DateSerializationRoundtripWorks() [Fact] public void DateTimeSerializationRoundtripWorks() { - Invoices::DueDate value = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + DueDate value = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); diff --git a/src/Orb.Tests/Models/Invoices/InvoiceDeleteLineItemParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceDeleteLineItemParamsTest.cs index 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/InvoiceFetchUpcomingResponseTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceFetchUpcomingResponseTest.cs index 9439dde18..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"), @@ -2202,6 +2244,356 @@ 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"], + }, + ], + 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", + }, + }, + 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 @@ -2292,7 +2684,23 @@ public void Validation_Works() PreviouslyAttemptedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; - model.Validate(); + 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); } } @@ -2406,6 +2814,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 +2969,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 @@ -2816,6 +3265,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2883,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"), @@ -2985,6 +3441,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3048,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"); @@ -3190,6 +3653,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3257,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"), @@ -3374,6 +3844,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3441,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"), @@ -3551,6 +4028,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3614,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"); @@ -3756,6 +4240,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3823,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"), @@ -3854,6 +4345,192 @@ 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"], + }, + ], + 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", + }, + }, + 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 +5063,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/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/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/Invoices/InvoiceListPageResponseTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceListPageResponseTest.cs index fa6499a9c..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"), @@ -2117,4 +2159,363 @@ 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"], + }, + ], + 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", + }, + }, + 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/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/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/InvoiceListSummaryParamsTest.cs b/src/Orb.Tests/Models/Invoices/InvoiceListSummaryParamsTest.cs index 60d010678..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; @@ -32,7 +31,6 @@ public void FieldRoundtrip_Works() IsRecurring = true, Limit = 1, Status = InvoiceListSummaryParamsStatus.Draft, - StatusValue = [StatusModel.Draft], SubscriptionID = "subscription_id", }; @@ -56,7 +54,6 @@ public void FieldRoundtrip_Works() long expectedLimit = 1; ApiEnum expectedStatus = InvoiceListSummaryParamsStatus.Draft; - List> expectedStatusValue = [StatusModel.Draft]; string expectedSubscriptionID = "subscription_id"; Assert.Equal(expectedAmount, parameters.Amount); @@ -77,12 +74,6 @@ public void FieldRoundtrip_Works() 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.Equal(expectedStatusValue[i], parameters.StatusValue[i]); - } Assert.Equal(expectedSubscriptionID, parameters.SubscriptionID); } @@ -108,7 +99,6 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() InvoiceDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), IsRecurring = true, Status = InvoiceListSummaryParamsStatus.Draft, - StatusValue = [StatusModel.Draft], SubscriptionID = "subscription_id", }; @@ -138,7 +128,6 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() InvoiceDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), IsRecurring = true, Status = InvoiceListSummaryParamsStatus.Draft, - StatusValue = [StatusModel.Draft], SubscriptionID = "subscription_id", // Null should be interpreted as omitted for these properties @@ -188,8 +177,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 +205,6 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() InvoiceDateLte = null, IsRecurring = null, Status = null, - StatusValue = null, SubscriptionID = null, }; @@ -256,8 +242,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 +268,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", }; @@ -293,11 +276,42 @@ 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 ); } + + [Fact] + public void CopyConstructor_Works() + { + var parameters = new InvoiceListSummaryParams + { + Amount = "amount", + AmountGt = "amount[gt]", + AmountLt = "amount[lt]", + Cursor = "cursor", + CustomerID = "customer_id", + DateType = InvoiceListSummaryParamsDateType.DueDate, + DueDate = "2019-12-27", + DueDateWindow = "due_date_window", + DueDateGt = "2019-12-27", + DueDateLt = "2019-12-27", + ExternalCustomerID = "external_customer_id", + InvoiceDateGt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + InvoiceDateGte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + InvoiceDateLt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + InvoiceDateLte = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + IsRecurring = true, + Limit = 1, + Status = InvoiceListSummaryParamsStatus.Draft, + SubscriptionID = "subscription_id", + }; + + InvoiceListSummaryParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class InvoiceListSummaryParamsDateTypeTest : TestBase @@ -417,67 +431,3 @@ public void InvalidEnumSerializationRoundtrip_Works() Assert.Equal(value, deserialized); } } - -public class StatusModelTest : TestBase -{ - [Theory] - [InlineData(StatusModel.Draft)] - [InlineData(StatusModel.Issued)] - [InlineData(StatusModel.Paid)] - [InlineData(StatusModel.Synced)] - [InlineData(StatusModel.Void)] - public void Validation_Works(StatusModel rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(StatusModel.Draft)] - [InlineData(StatusModel.Issued)] - [InlineData(StatusModel.Paid)] - [InlineData(StatusModel.Synced)] - [InlineData(StatusModel.Void)] - public void SerializationRoundtrip_Works(StatusModel rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} diff --git a/src/Orb.Tests/Models/Invoices/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/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..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); @@ -87,6 +95,24 @@ 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", + AutoCollection = true, + 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/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/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/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/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/ItemTest.cs b/src/Orb.Tests/Models/Items/ItemTest.cs index 009d3f05a..6ffe3de58 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 @@ -350,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 @@ -377,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 8d3b688be..5c18118be 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 @@ -173,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 @@ -186,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 @@ -214,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/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/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..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,10 +233,101 @@ 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] public void Validation_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 = + [ + 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 { @@ -216,6 +357,116 @@ public void Validation_Works() 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(); + } + + [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, + ParameterDefinitions = + [ + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ], + }; + + BillableMetric copied = new(model); + + Assert.Equal(model, copied); + } } public class StatusTest : 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/MetricListPageResponseTest.cs b/src/Orb.Tests/Models/Metrics/MetricListPageResponseTest.cs index 317bd3c4e..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" }, @@ -256,4 +298,52 @@ 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, + ParameterDefinitions = + [ + new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + ], + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + MetricListPageResponse copied = new(model); + + Assert.Equal(model, 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/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..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,10 +423,44 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ExpiresAtEndOfCadence = null, Filters = null, ItemID = null, + LicenseTypeID = null, }; 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }; + + NewAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class CadenceTest : TestBase @@ -566,6 +617,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..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,11 +459,59 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,11 +509,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingBulkWithProrationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithProrationConfigTest : TestBase @@ -597,6 +663,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 +774,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..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,11 +579,71 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingCumulativeGroupedBulkPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingCumulativeGroupedBulkPriceCadenceTest : TestBase @@ -761,6 +834,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 +936,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..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,11 +509,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingGroupedAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingGroupedAllocationPriceCadenceTest : TestBase @@ -643,6 +709,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..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,11 +549,68 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingGroupedTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingGroupedTieredPackagePriceCadenceTest : TestBase @@ -715,6 +785,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 +876,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..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,11 +539,67 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingGroupedTieredPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingGroupedTieredPriceCadenceTest : TestBase @@ -697,6 +766,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 +856,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..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,11 +613,74 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingGroupedWithMeteredMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingGroupedWithMeteredMinimumPriceCadenceTest : TestBase @@ -825,6 +901,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 +997,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 +1083,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..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,11 +523,65 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingGroupedWithProratedMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingGroupedWithProratedMinimumPriceCadenceTest : TestBase @@ -659,6 +726,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..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,11 +509,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,11 +519,65 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,11 +579,71 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingMatrixWithDisplayNamePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingMatrixWithDisplayNamePriceCadenceTest : TestBase @@ -761,6 +834,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 +936,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..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,11 +549,68 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingMaxGroupTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingMaxGroupTieredPackagePriceCadenceTest : TestBase @@ -715,6 +785,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 +876,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..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,11 +467,59 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingMinimumCompositePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingMinimumCompositePriceCadenceTest : TestBase @@ -639,6 +700,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..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,11 +467,59 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,11 +509,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingPackageWithAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingPackageWithAllocationPriceCadenceTest : TestBase @@ -697,6 +763,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..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,11 +661,78 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingScalableMatrixWithTieredPricingPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingScalableMatrixWithTieredPricingPriceCadenceTest : TestBase @@ -1057,6 +1137,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 +1299,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 +1386,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..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", }, @@ -62,6 +63,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -85,6 +87,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -116,6 +119,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 +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) @@ -171,6 +176,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -201,6 +207,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -238,6 +245,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -268,6 +276,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -299,6 +308,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -330,6 +340,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 +365,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 +400,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -418,6 +431,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -448,6 +462,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -473,6 +488,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")); } @@ -501,6 +518,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -533,6 +551,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -547,6 +566,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -570,6 +590,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")); } @@ -598,6 +620,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -612,11 +635,76 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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", + GroupingKey = "x", + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingScalableMatrixWithUnitPricingPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingScalableMatrixWithUnitPricingPriceCadenceTest : TestBase @@ -759,6 +847,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -774,6 +863,7 @@ public void FieldRoundtrip_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -784,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); } @@ -804,6 +895,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -833,6 +925,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -855,6 +948,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -865,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); } @@ -885,6 +980,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -910,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); @@ -954,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); @@ -981,12 +1082,39 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ], 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 ScalableMatrixWithUnitPricingConfigMatrixScalingFactorTest : TestBase @@ -1123,6 +1251,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..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,11 +539,67 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingThresholdTotalAmountPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingThresholdTotalAmountPriceCadenceTest : TestBase @@ -815,6 +884,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 +958,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..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,11 +539,67 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingTieredPackagePriceCadenceTest : TestBase @@ -749,6 +818,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 +908,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..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,11 +642,77 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingTieredPackageWithMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingTieredPackageWithMinimumPriceCadenceTest : TestBase @@ -916,6 +995,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 +1103,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..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,11 +579,71 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,11 +649,78 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingTieredWithMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingTieredWithMinimumPriceCadenceTest : TestBase @@ -1041,6 +1121,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 +1230,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..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,11 +479,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingTieredWithProrationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingTieredWithProrationPriceCadenceTest : TestBase @@ -663,6 +726,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 +811,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..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,11 +459,59 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,11 +467,59 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingUnitWithPercentPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingUnitWithPercentPriceCadenceTest : TestBase @@ -629,6 +690,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..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,11 +459,59 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + NewFloatingUnitWithProrationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewFloatingUnitWithProrationPriceCadenceTest : TestBase @@ -617,6 +678,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..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,12 +476,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,12 +524,66 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanBulkWithProrationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanBulkWithProrationPriceBulkWithProrationConfigTest : TestBase @@ -615,6 +682,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 +823,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..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,12 +596,73 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanCumulativeGroupedBulkPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanCumulativeGroupedBulkPriceCadenceTest : TestBase @@ -781,6 +855,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 +960,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..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,12 +524,66 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanGroupedAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedAllocationPriceCadenceTest : TestBase @@ -661,6 +728,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..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,12 +566,70 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanGroupedTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedTieredPackagePriceCadenceTest : TestBase @@ -735,6 +806,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 +899,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..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,12 +554,69 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanGroupedTieredPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedTieredPriceCadenceTest : TestBase @@ -715,6 +785,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 +877,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..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,12 +622,75 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanGroupedWithMeteredMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedWithMeteredMinimumPriceCadenceTest : TestBase @@ -823,6 +899,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 +999,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 +1094,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..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,12 +532,66 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanGroupedWithProratedMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanGroupedWithProratedMinimumPriceCadenceTest : TestBase @@ -669,6 +736,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..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,12 +524,66 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,12 +534,67 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,12 +596,73 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanMatrixWithDisplayNamePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanMatrixWithDisplayNamePriceCadenceTest : TestBase @@ -781,6 +855,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 +959,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..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,12 +566,70 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanMaxGroupTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanMaxGroupTieredPackagePriceCadenceTest : TestBase @@ -735,6 +806,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 +899,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..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,12 +482,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanMinimumCompositePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanMinimumCompositePriceCadenceTest : TestBase @@ -663,6 +725,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..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,12 +482,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,12 +526,66 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanPackageWithAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanPackageWithAllocationPriceCadenceTest : TestBase @@ -715,6 +782,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..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,12 +670,80 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanScalableMatrixWithTieredPricingPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanScalableMatrixWithTieredPricingPriceCadenceTest : TestBase @@ -1078,6 +1159,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 +1334,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 +1430,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..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", }, @@ -62,6 +63,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -86,6 +88,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -118,6 +121,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 +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) @@ -174,6 +179,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -205,6 +211,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -241,6 +248,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -272,6 +280,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -303,6 +312,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -335,6 +345,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 +371,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 +406,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -425,6 +438,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -455,6 +469,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -482,6 +497,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); @@ -511,6 +528,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -542,6 +560,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -557,6 +576,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -583,6 +603,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); @@ -612,6 +634,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -627,12 +650,78 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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", + GroupingKey = "x", + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanScalableMatrixWithUnitPricingPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanScalableMatrixWithUnitPricingPriceCadenceTest : TestBase @@ -772,6 +861,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -787,6 +877,7 @@ public void FieldRoundtrip_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -797,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); } @@ -817,6 +909,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -847,6 +940,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -870,6 +964,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -880,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); } @@ -900,6 +996,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -925,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); @@ -969,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); @@ -996,12 +1098,41 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ], UnitPrice = "unit_price", + GroupingKey = null, Prorate = null, SecondDimension = null, }; 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", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfig copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfigMatrixScalingFactorTest @@ -1147,6 +1278,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..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,12 +556,69 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanThresholdTotalAmountPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanThresholdTotalAmountPriceCadenceTest : TestBase @@ -835,6 +905,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 +998,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..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,12 +554,69 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanTieredPackagePriceCadenceTest : TestBase @@ -769,6 +839,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 +931,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..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,12 +659,79 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanTieredPackageWithMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanTieredPackageWithMinimumPriceCadenceTest : TestBase @@ -932,6 +1012,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 +1122,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..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,12 +594,73 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,12 +664,80 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanTieredWithMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanTieredWithMinimumPriceCadenceTest : TestBase @@ -1059,6 +1140,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 +1251,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..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,12 +472,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,12 +482,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanUnitWithPercentPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanUnitWithPercentPriceCadenceTest : TestBase @@ -665,6 +727,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..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,12 +478,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + NewPlanUnitWithProrationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewPlanUnitWithProrationPriceCadenceTest : TestBase @@ -651,6 +713,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..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", @@ -1234,4 +1304,136 @@ 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"], + }, + ], + 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", + }, + }, + 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/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/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/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/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/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/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 0ff196c74..1c35b8942 100644 --- a/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Plans/PlanCreateParamsTest.cs @@ -42,8 +42,57 @@ public void FieldRoundtrip_Works() }, ], 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() { @@ -81,6 +130,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -158,8 +208,57 @@ public void FieldRoundtrip_Works() }, ], 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() { @@ -197,6 +296,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -310,8 +410,57 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() }, ], 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() { @@ -349,6 +498,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -434,8 +584,57 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() }, ], 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() { @@ -473,6 +672,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -561,8 +761,57 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() }, ], 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() { @@ -600,6 +849,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -654,8 +904,57 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() }, ], 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() { @@ -693,6 +992,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -754,14 +1054,22 @@ public void Url_Works() }, ], ItemID = "item_id", + 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", @@ -793,10 +1101,52 @@ public void Url_Works() 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", + }, + }, ], }; @@ -804,6 +1154,182 @@ 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", + 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", + }, + }, + ], + 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 @@ -834,8 +1360,57 @@ public void FieldRoundtrip_Works() }, ], 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() { @@ -873,6 +1448,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -899,18 +1475,66 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; - long expectedPlanPhaseOrder = 0; - PricePrice expectedPriceValue = new Models::NewPlanUnitPrice() + LicenseAllocationPrice expectedLicenseAllocationPrice = new Unit() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Cadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, + 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() + { + 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, @@ -937,11 +1561,13 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; Assert.Equal(expectedAllocationPrice, model.AllocationPrice); + Assert.Equal(expectedLicenseAllocationPrice, model.LicenseAllocationPrice); Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); Assert.Equal(expectedPriceValue, model.PriceValue); } @@ -972,8 +1598,57 @@ public void SerializationRoundtrip_Works() }, ], 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() { @@ -1011,6 +1686,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1048,8 +1724,57 @@ public void FieldRoundtripThroughSerialization_Works() }, ], 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() { @@ -1087,6 +1812,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1117,8 +1843,56 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + 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() { @@ -1155,11 +1929,13 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); + Assert.Equal(expectedLicenseAllocationPrice, deserialized.LicenseAllocationPrice); Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); Assert.Equal(expectedPriceValue, deserialized.PriceValue); } @@ -1190,8 +1966,57 @@ public void Validation_Works() }, ], 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() { @@ -1229,6 +2054,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1244,6 +2070,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.PriceValue); @@ -1264,12 +2092,15 @@ 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); @@ -1282,35 +2113,169 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() var model = new Price { AllocationPrice = null, + LicenseAllocationPrice = null, PlanPhaseOrder = null, PriceValue = null, }; model.Validate(); } -} -public class PricePriceTest : TestBase -{ [Fact] - public void NewPlanUnitValidationWorks() + public void CopyConstructor_Works() { - PricePrice value = new Models::NewPlanUnitPrice() + var model = new Price { - 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() + AllocationPrice = new() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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", }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + 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"), @@ -1330,6 +2295,7 @@ public void NewPlanUnitValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1337,13 +2303,21 @@ public void NewPlanUnitValidationWorks() } [Fact] - public void NewPlanTieredValidationWorks() + public void TieredValidationWorks() { - PricePrice 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() { @@ -1386,6 +2360,7 @@ public void NewPlanTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1393,14 +2368,22 @@ public void NewPlanTieredValidationWorks() } [Fact] - public void NewPlanBulkValidationWorks() + public void BulkValidationWorks() { - PricePrice 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, @@ -1430,6 +2413,7 @@ public void NewPlanBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1439,7 +2423,7 @@ public void NewPlanBulkValidationWorks() [Fact] public void BulkWithFiltersValidationWorks() { - PricePrice value = new BulkWithFilters() + LicenseAllocationPrice value = new BulkWithFilters() { BulkWithFiltersConfig = new() { @@ -1450,8 +2434,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, @@ -1481,6 +2474,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1488,13 +2482,21 @@ public void BulkWithFiltersValidationWorks() } [Fact] - public void NewPlanPackageValidationWorks() + public void PackageValidationWorks() { - PricePrice 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", @@ -1525,6 +2527,7 @@ public void NewPlanPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1532,19 +2535,27 @@ public void NewPlanPackageValidationWorks() } [Fact] - public void NewPlanMatrixValidationWorks() + public void MatrixValidationWorks() { - PricePrice 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, @@ -1574,6 +2585,7 @@ public void NewPlanMatrixValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1581,13 +2593,21 @@ public void NewPlanMatrixValidationWorks() } [Fact] - public void NewPlanThresholdTotalAmountValidationWorks() + public void ThresholdTotalAmountValidationWorks() { - PricePrice 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() { @@ -1626,6 +2646,7 @@ public void NewPlanThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1633,13 +2654,21 @@ public void NewPlanThresholdTotalAmountValidationWorks() } [Fact] - public void NewPlanTieredPackageValidationWorks() + public void TieredPackageValidationWorks() { - PricePrice 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() { @@ -1678,6 +2707,7 @@ public void NewPlanTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1685,13 +2715,21 @@ public void NewPlanTieredPackageValidationWorks() } [Fact] - public void NewPlanTieredWithMinimumValidationWorks() + public void TieredWithMinimumValidationWorks() { - PricePrice 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() { @@ -1741,6 +2779,7 @@ public void NewPlanTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1748,11 +2787,11 @@ public void NewPlanTieredWithMinimumValidationWorks() } [Fact] - public void NewPlanGroupedTieredValidationWorks() + public void GroupedTieredValidationWorks() { - PricePrice value = new Models::NewPlanGroupedTieredPrice() + LicenseAllocationPrice value = new GroupedTiered() { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, + Cadence = GroupedTieredCadence.Annual, GroupedTieredConfig = new() { GroupingKey = "x", @@ -1763,7 +2802,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, @@ -1793,6 +2840,7 @@ public void NewPlanGroupedTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1800,14 +2848,21 @@ public void NewPlanGroupedTieredValidationWorks() } [Fact] - public void NewPlanTieredPackageWithMinimumValidationWorks() + public void TieredPackageWithMinimumValidationWorks() { - PricePrice 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() { @@ -1856,6 +2911,7 @@ public void NewPlanTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1863,13 +2919,21 @@ public void NewPlanTieredPackageWithMinimumValidationWorks() } [Fact] - public void NewPlanPackageWithAllocationValidationWorks() + public void PackageWithAllocationValidationWorks() { - PricePrice 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() { @@ -1905,6 +2969,7 @@ public void NewPlanPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1912,13 +2977,21 @@ public void NewPlanPackageWithAllocationValidationWorks() } [Fact] - public void NewPlanUnitWithPercentValidationWorks() + public void UnitWithPercentValidationWorks() { - PricePrice 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", @@ -1949,6 +3022,7 @@ public void NewPlanUnitWithPercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -1956,12 +3030,21 @@ public void NewPlanUnitWithPercentValidationWorks() } [Fact] - public void NewPlanMatrixWithAllocationValidationWorks() + public void MatrixWithAllocationValidationWorks() { - PricePrice 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", @@ -1969,7 +3052,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, @@ -1999,6 +3081,7 @@ public void NewPlanMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2008,10 +3091,19 @@ public void NewPlanMatrixWithAllocationValidationWorks() [Fact] public void TieredWithProrationValidationWorks() { - PricePrice 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" }] @@ -2044,6 +3136,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2051,18 +3144,26 @@ public void TieredWithProrationValidationWorks() } [Fact] - public void NewPlanUnitWithProrationValidationWorks() + public void UnitWithProrationValidationWorks() { - PricePrice value = new Models::NewPlanUnitWithProrationPrice() + LicenseAllocationPrice value = new UnitWithProration() { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = UnitWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, - Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + 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, @@ -2088,6 +3189,7 @@ public void NewPlanUnitWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2095,11 +3197,11 @@ public void NewPlanUnitWithProrationValidationWorks() } [Fact] - public void NewPlanGroupedAllocationValidationWorks() + public void GroupedAllocationValidationWorks() { - PricePrice value = new Models::NewPlanGroupedAllocationPrice() + LicenseAllocationPrice value = new GroupedAllocation() { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + Cadence = GroupedAllocationCadence.Annual, GroupedAllocationConfig = new() { Allocation = "allocation", @@ -2107,7 +3209,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, @@ -2137,6 +3247,7 @@ public void NewPlanGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2144,9 +3255,9 @@ public void NewPlanGroupedAllocationValidationWorks() } [Fact] - public void NewPlanBulkWithProrationValidationWorks() + public void BulkWithProrationValidationWorks() { - PricePrice value = new Models::NewPlanBulkWithProrationPrice() + LicenseAllocationPrice value = new BulkWithProration() { BulkWithProrationConfig = new( [ @@ -2154,9 +3265,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, @@ -2186,6 +3305,7 @@ public void NewPlanBulkWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2193,11 +3313,11 @@ public void NewPlanBulkWithProrationValidationWorks() } [Fact] - public void NewPlanGroupedWithProratedMinimumValidationWorks() + public void GroupedWithProratedMinimumValidationWorks() { - PricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() + LicenseAllocationPrice value = new GroupedWithProratedMinimum() { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + Cadence = GroupedWithProratedMinimumCadence.Annual, GroupedWithProratedMinimumConfig = new() { GroupingKey = "x", @@ -2205,8 +3325,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, @@ -2236,6 +3363,7 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2243,11 +3371,11 @@ public void NewPlanGroupedWithProratedMinimumValidationWorks() } [Fact] - public void NewPlanGroupedWithMeteredMinimumValidationWorks() + public void GroupedWithMeteredMinimumValidationWorks() { - PricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + LicenseAllocationPrice value = new GroupedWithMeteredMinimum() { - Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + Cadence = GroupedWithMeteredMinimumCadence.Annual, GroupedWithMeteredMinimumConfig = new() { GroupingKey = "x", @@ -2255,17 +3383,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, @@ -2295,6 +3430,7 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2304,7 +3440,7 @@ public void NewPlanGroupedWithMeteredMinimumValidationWorks() [Fact] public void GroupedWithMinMaxThresholdsValidationWorks() { - PricePrice value = new GroupedWithMinMaxThresholds() + LicenseAllocationPrice value = new GroupedWithMinMaxThresholds() { Cadence = GroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() @@ -2315,6 +3451,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, @@ -2344,6 +3489,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2351,12 +3497,21 @@ public void GroupedWithMinMaxThresholdsValidationWorks() } [Fact] - public void NewPlanMatrixWithDisplayNameValidationWorks() + public void MatrixWithDisplayNameValidationWorks() { - PricePrice 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", @@ -2370,7 +3525,6 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() }, ], }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2400,6 +3554,7 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2407,11 +3562,11 @@ public void NewPlanMatrixWithDisplayNameValidationWorks() } [Fact] - public void NewPlanGroupedTieredPackageValidationWorks() + public void GroupedTieredPackageValidationWorks() { - PricePrice value = new Models::NewPlanGroupedTieredPackagePrice() + LicenseAllocationPrice value = new GroupedTieredPackage() { - Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, + Cadence = GroupedTieredPackageCadence.Annual, GroupedTieredPackageConfig = new() { GroupingKey = "x", @@ -2423,7 +3578,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, @@ -2453,6 +3616,7 @@ public void NewPlanGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2460,12 +3624,21 @@ public void NewPlanGroupedTieredPackageValidationWorks() } [Fact] - public void NewPlanMaxGroupTieredPackageValidationWorks() + public void MaxGroupTieredPackageValidationWorks() { - PricePrice 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", @@ -2476,7 +3649,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, @@ -2506,6 +3678,7 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2513,14 +3686,21 @@ public void NewPlanMaxGroupTieredPackageValidationWorks() } [Fact] - public void NewPlanScalableMatrixWithUnitPricingValidationWorks() + public void ScalableMatrixWithUnitPricingValidationWorks() { - PricePrice 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() { @@ -2535,6 +3715,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -2566,6 +3747,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2573,14 +3755,21 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() } [Fact] - public void NewPlanScalableMatrixWithTieredPricingValidationWorks() + public void ScalableMatrixWithTieredPricingValidationWorks() { - PricePrice 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() { @@ -2629,6 +3818,7 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2636,11 +3826,11 @@ public void NewPlanScalableMatrixWithTieredPricingValidationWorks() } [Fact] - public void NewPlanCumulativeGroupedBulkValidationWorks() + public void CumulativeGroupedBulkValidationWorks() { - PricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() + LicenseAllocationPrice value = new CumulativeGroupedBulk() { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + Cadence = CumulativeGroupedBulkCadence.Annual, CumulativeGroupedBulkConfig = new() { DimensionValues = @@ -2655,7 +3845,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, @@ -2685,6 +3883,7 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2694,7 +3893,7 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() [Fact] public void CumulativeGroupedAllocationValidationWorks() { - PricePrice value = new CumulativeGroupedAllocation() + LicenseAllocationPrice value = new CumulativeGroupedAllocation() { Cadence = CumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() @@ -2705,6 +3904,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, @@ -2734,6 +3942,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2741,57 +3950,22 @@ public void CumulativeGroupedAllocationValidationWorks() } [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() + public void MinimumCompositeValidationWorks() { - PricePrice 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, @@ -2821,6 +3995,7 @@ public void NewPlanMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2830,10 +4005,19 @@ public void NewPlanMinimumCompositeValidationWorks() [Fact] public void PercentValidationWorks() { - PricePrice 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", @@ -2864,6 +4048,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2873,7 +4058,7 @@ public void PercentValidationWorks() [Fact] public void EventOutputValidationWorks() { - PricePrice value = new EventOutput() + LicenseAllocationPrice value = new EventOutput() { Cadence = EventOutputCadence.Annual, EventOutputConfig = new() @@ -2883,6 +4068,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, @@ -2912,6 +4106,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2919,13 +4114,21 @@ public void EventOutputValidationWorks() } [Fact] - public void NewPlanUnitSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - PricePrice 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", @@ -2956,11 +4159,12 @@ public void NewPlanUnitSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -2969,13 +4173,21 @@ public void NewPlanUnitSerializationRoundtripWorks() } [Fact] - public void NewPlanTieredSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - PricePrice 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() { @@ -3018,11 +4230,12 @@ public void NewPlanTieredSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3031,14 +4244,22 @@ public void NewPlanTieredSerializationRoundtripWorks() } [Fact] - public void NewPlanBulkSerializationRoundtripWorks() + public void BulkSerializationRoundtripWorks() { - PricePrice 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, @@ -3068,11 +4289,12 @@ public void NewPlanBulkSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3083,7 +4305,7 @@ public void NewPlanBulkSerializationRoundtripWorks() [Fact] public void BulkWithFiltersSerializationRoundtripWorks() { - PricePrice value = new BulkWithFilters() + LicenseAllocationPrice value = new BulkWithFilters() { BulkWithFiltersConfig = new() { @@ -3094,8 +4316,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, @@ -3125,11 +4356,12 @@ public void BulkWithFiltersSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3138,13 +4370,21 @@ public void BulkWithFiltersSerializationRoundtripWorks() } [Fact] - public void NewPlanPackageSerializationRoundtripWorks() + public void PackageSerializationRoundtripWorks() { - PricePrice 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", @@ -3175,11 +4415,12 @@ public void NewPlanPackageSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3188,19 +4429,27 @@ public void NewPlanPackageSerializationRoundtripWorks() } [Fact] - public void NewPlanMatrixSerializationRoundtripWorks() + public void MatrixSerializationRoundtripWorks() { - PricePrice 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, @@ -3230,11 +4479,12 @@ public void NewPlanMatrixSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3243,13 +4493,21 @@ public void NewPlanMatrixSerializationRoundtripWorks() } [Fact] - public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() + public void ThresholdTotalAmountSerializationRoundtripWorks() { - PricePrice 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() { @@ -3288,11 +4546,12 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3301,13 +4560,21 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() } [Fact] - public void NewPlanTieredPackageSerializationRoundtripWorks() + public void TieredPackageSerializationRoundtripWorks() { - PricePrice 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() { @@ -3346,11 +4613,12 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3359,13 +4627,21 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() } [Fact] - public void NewPlanTieredWithMinimumSerializationRoundtripWorks() + public void TieredWithMinimumSerializationRoundtripWorks() { - PricePrice 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() { @@ -3415,11 +4691,12 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3428,11 +4705,11 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() } [Fact] - public void NewPlanGroupedTieredSerializationRoundtripWorks() + public void GroupedTieredSerializationRoundtripWorks() { - PricePrice value = new Models::NewPlanGroupedTieredPrice() + LicenseAllocationPrice value = new GroupedTiered() { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, + Cadence = GroupedTieredCadence.Annual, GroupedTieredConfig = new() { GroupingKey = "x", @@ -3443,7 +4720,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, @@ -3473,11 +4758,12 @@ public void NewPlanGroupedTieredSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3486,14 +4772,21 @@ public void NewPlanGroupedTieredSerializationRoundtripWorks() } [Fact] - public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + public void TieredPackageWithMinimumSerializationRoundtripWorks() { - PricePrice 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() { @@ -3542,11 +4835,12 @@ public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3555,13 +4849,21 @@ public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() } [Fact] - public void NewPlanPackageWithAllocationSerializationRoundtripWorks() + public void PackageWithAllocationSerializationRoundtripWorks() { - PricePrice 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() { @@ -3597,11 +4899,12 @@ public void NewPlanPackageWithAllocationSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3610,13 +4913,21 @@ public void NewPlanPackageWithAllocationSerializationRoundtripWorks() } [Fact] - public void NewPlanUnitWithPercentSerializationRoundtripWorks() + public void UnitWithPercentSerializationRoundtripWorks() { - PricePrice 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", @@ -3647,11 +4958,12 @@ public void NewPlanUnitWithPercentSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3660,12 +4972,21 @@ public void NewPlanUnitWithPercentSerializationRoundtripWorks() } [Fact] - public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() + public void MatrixWithAllocationSerializationRoundtripWorks() { - PricePrice 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", @@ -3673,7 +4994,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, @@ -3703,11 +5023,12 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3718,10 +5039,19 @@ public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() [Fact] public void TieredWithProrationSerializationRoundtripWorks() { - PricePrice 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" }] @@ -3754,11 +5084,12 @@ public void TieredWithProrationSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3767,13 +5098,21 @@ public void TieredWithProrationSerializationRoundtripWorks() } [Fact] - public void NewPlanUnitWithProrationSerializationRoundtripWorks() + public void UnitWithProrationSerializationRoundtripWorks() { - PricePrice 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", @@ -3804,11 +5143,12 @@ public void NewPlanUnitWithProrationSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3817,11 +5157,11 @@ public void NewPlanUnitWithProrationSerializationRoundtripWorks() } [Fact] - public void NewPlanGroupedAllocationSerializationRoundtripWorks() + public void GroupedAllocationSerializationRoundtripWorks() { - PricePrice value = new Models::NewPlanGroupedAllocationPrice() + LicenseAllocationPrice value = new GroupedAllocation() { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + Cadence = GroupedAllocationCadence.Annual, GroupedAllocationConfig = new() { Allocation = "allocation", @@ -3829,7 +5169,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, @@ -3859,11 +5207,12 @@ public void NewPlanGroupedAllocationSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3872,9 +5221,9 @@ public void NewPlanGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void NewPlanBulkWithProrationSerializationRoundtripWorks() + public void BulkWithProrationSerializationRoundtripWorks() { - PricePrice value = new Models::NewPlanBulkWithProrationPrice() + LicenseAllocationPrice value = new BulkWithProration() { BulkWithProrationConfig = new( [ @@ -3882,9 +5231,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, @@ -3914,11 +5271,12 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3927,11 +5285,11 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() } [Fact] - public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() + public void GroupedWithProratedMinimumSerializationRoundtripWorks() { - PricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() + LicenseAllocationPrice value = new GroupedWithProratedMinimum() { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + Cadence = GroupedWithProratedMinimumCadence.Annual, GroupedWithProratedMinimumConfig = new() { GroupingKey = "x", @@ -3939,8 +5297,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, @@ -3970,11 +5335,12 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -3983,11 +5349,11 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() } [Fact] - public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void GroupedWithMeteredMinimumSerializationRoundtripWorks() { - PricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + LicenseAllocationPrice value = new GroupedWithMeteredMinimum() { - Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + Cadence = GroupedWithMeteredMinimumCadence.Annual, GroupedWithMeteredMinimumConfig = new() { GroupingKey = "x", @@ -3995,17 +5361,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, @@ -4035,11 +5408,12 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -4050,7 +5424,7 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() [Fact] public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - PricePrice value = new GroupedWithMinMaxThresholds() + LicenseAllocationPrice value = new GroupedWithMinMaxThresholds() { Cadence = GroupedWithMinMaxThresholdsCadence.Annual, GroupedWithMinMaxThresholdsConfig = new() @@ -4061,6 +5435,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, @@ -4090,11 +5473,12 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -4103,12 +5487,21 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() } [Fact] - public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + public void MatrixWithDisplayNameSerializationRoundtripWorks() { - PricePrice 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", @@ -4122,7 +5515,6 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() }, ], }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4152,11 +5544,12 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -4165,11 +5558,11 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() } [Fact] - public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() + public void GroupedTieredPackageSerializationRoundtripWorks() { - PricePrice value = new Models::NewPlanGroupedTieredPackagePrice() + LicenseAllocationPrice value = new GroupedTieredPackage() { - Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, + Cadence = GroupedTieredPackageCadence.Annual, GroupedTieredPackageConfig = new() { GroupingKey = "x", @@ -4181,7 +5574,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, @@ -4211,11 +5612,12 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -4224,12 +5626,21 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() } [Fact] - public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + public void MaxGroupTieredPackageSerializationRoundtripWorks() { - PricePrice 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", @@ -4240,7 +5651,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, @@ -4270,11 +5680,12 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -4283,14 +5694,21 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() } [Fact] - public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() { - PricePrice 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() { @@ -4305,6 +5723,7 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -4336,11 +5755,12 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -4349,14 +5769,21 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() } [Fact] - public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - PricePrice 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() { @@ -4405,11 +5832,12 @@ public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -4418,11 +5846,11 @@ public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() } [Fact] - public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + public void CumulativeGroupedBulkSerializationRoundtripWorks() { - PricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() + LicenseAllocationPrice value = new CumulativeGroupedBulk() { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + Cadence = CumulativeGroupedBulkCadence.Annual, CumulativeGroupedBulkConfig = new() { DimensionValues = @@ -4437,7 +5865,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, @@ -4467,11 +5903,12 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -4482,7 +5919,7 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() [Fact] public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - PricePrice value = new CumulativeGroupedAllocation() + LicenseAllocationPrice value = new CumulativeGroupedAllocation() { Cadence = CumulativeGroupedAllocationCadence.Annual, CumulativeGroupedAllocationConfig = new() @@ -4493,6 +5930,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, @@ -4522,11 +5968,12 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -4535,13 +5982,22 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void MinimumCompositeSerializationRoundtripWorks() { - PricePrice value = new Minimum() + LicenseAllocationPrice value = new MinimumComposite() { - Cadence = MinimumCadence.Annual, + Cadence = MinimumCompositeCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4571,11 +6027,12 @@ public void MinimumSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -4584,62 +6041,21 @@ public void MinimumSerializationRoundtripWorks() } [Fact] - public void NewPlanMinimumCompositeSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { - PricePrice value = new Models::NewPlanMinimumCompositePrice() + LicenseAllocationPrice value = new Percent() { - 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() - { - PricePrice value = new Percent() - { - Cadence = PercentCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", + LicenseAllocations = + [ + new() + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }, + ], Name = "Annual fee", PercentConfig = new(0), BillableMetricID = "billable_metric_id", @@ -4670,11 +6086,12 @@ public void PercentSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -4685,7 +6102,7 @@ public void PercentSerializationRoundtripWorks() [Fact] public void EventOutputSerializationRoundtripWorks() { - PricePrice value = new EventOutput() + LicenseAllocationPrice value = new EventOutput() { Cadence = EventOutputCadence.Annual, EventOutputConfig = new() @@ -4695,6 +6112,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, @@ -4724,11 +6150,12 @@ public void EventOutputSerializationRoundtripWorks() 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( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -4737,25 +6164,26 @@ public void EventOutputSerializationRoundtripWorks() } } -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() @@ -4784,23 +6212,29 @@ public void FieldRoundtrip_Works() 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 = 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() @@ -4830,14 +6264,20 @@ public void FieldRoundtrip_Works() 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(expectedUnitConfig, model.UnitConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -4849,6 +6289,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) @@ -4863,20 +6304,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() @@ -4905,15 +6347,13 @@ public void SerializationRoundtrip_Works() 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 - ); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -4921,20 +6361,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() @@ -4963,30 +6404,33 @@ public void FieldRoundtripThroughSerialization_Works() 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 - ); + 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() @@ -5016,14 +6460,20 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedUnitConfig, deserialized.UnitConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -5038,6 +6488,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) @@ -5052,20 +6503,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() @@ -5094,6 +6546,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5104,20 +6557,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); @@ -5142,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); @@ -5151,20 +6607,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(); @@ -5173,20 +6630,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, @@ -5199,6 +6657,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -5225,6 +6684,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); @@ -5234,20 +6695,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, @@ -5260,147 +6722,173 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } -} -public class BulkWithFiltersConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new BulkWithFiltersConfig + var model = new Unit { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + Cadence = Cadence.Annual, + ItemID = "item_id", + LicenseAllocations = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + 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", }; - 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" }, - ]; + Unit copied = new(model); - Assert.Equal(expectedFilters.Count, model.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], model.Filters[i]); - } - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + Assert.Equal(model, copied); } +} - [Fact] - public void SerializationRoundtrip_Works() +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) { - 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; + value.Validate(); + } - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, + [Fact] + public void InvalidEnumValidationThrows_Works() + { + 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]); - } + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void InvalidEnumSerializationRoundtrip_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" }, - ], - }; + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); - model.Validate(); + Assert.Equal(value, deserialized); } } -public class FilterTest : TestBase +public class LicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + 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); } @@ -5408,190 +6896,106 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + 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 expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; model.Validate(); } -} -public class TierTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; - - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + var model = new LicenseAllocation { Amount = "amount", Currency = "currency" }; - Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void SerializationRoundtrip_Works() + public void OptionalNullablePropertiesUnsetValidation_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); + var model = new LicenseAllocation { Amount = "amount", Currency = "currency" }; - Assert.Equal(model, deserialized); + model.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_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); + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + WriteOffOverage = null, + }; - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + + WriteOffOverage = null, + }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { - var model = new Tier { UnitAmount = "unit_amount" }; - - Assert.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); - } + var model = new LicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Tier { UnitAmount = "unit_amount" }; + LicenseAllocation copied = new(model); - model.Validate(); + Assert.Equal(model, copied); } +} - [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(); - } -} - -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 -{ +public class ConversionRateConfigTest : TestBase +{ [Fact] public void UnitValidationWorks() { @@ -5667,19 +7071,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() @@ -5708,18 +7131,37 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, 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() @@ -5728,7 +7170,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + TieredConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5749,14 +7191,20 @@ public void FieldRoundtrip_Works() 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(expectedTieredConfig, model.TieredConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -5768,6 +7216,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) @@ -5782,14 +7231,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() @@ -5818,15 +7286,13 @@ public void SerializationRoundtrip_Works() 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 - ); + var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); Assert.Equal(model, deserialized); } @@ -5834,14 +7300,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() @@ -5870,25 +7355,41 @@ public void FieldRoundtripThroughSerialization_Works() 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 - ); + 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() @@ -5897,7 +7398,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + TieredConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5918,14 +7419,20 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedTieredConfig, deserialized.TieredConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -5940,6 +7447,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) @@ -5954,14 +7462,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() @@ -5990,6 +7517,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6000,14 +7528,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", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + 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); @@ -6032,6 +7579,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); @@ -6041,14 +7590,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(); @@ -6057,14 +7625,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, @@ -6077,6 +7664,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6103,6 +7691,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); @@ -6112,14 +7702,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, @@ -6132,34 +7741,103 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() 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 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 ); @@ -6169,19 +7847,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 ); @@ -6192,12 +7870,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 ); @@ -6206,173 +7884,38883 @@ 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 ); - Assert.Equal(model, deserialized); + 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 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 PricePriceTest : TestBase +{ + [Fact] + public void NewPlanUnitValidationWorks() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice value = new PricePriceBulkWithFilters() + { + 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 = PricePriceBulkWithFiltersCadence.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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice value = new PricePriceTieredWithProration() + { + Cadence = PricePriceTieredWithProrationCadence.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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice value = new PricePriceGroupedWithMinMaxThresholds() + { + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice value = new PricePriceCumulativeGroupedAllocation() + { + Cadence = PricePriceCumulativeGroupedAllocationCadence.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() + { + PricePrice 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() + { + PricePrice value = new PricePricePercent() + { + Cadence = PricePricePercentCadence.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() + { + PricePrice value = new PricePriceEventOutput() + { + Cadence = PricePriceEventOutputCadence.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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice value = new PricePriceBulkWithFilters() + { + 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 = PricePriceBulkWithFiltersCadence.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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice value = new PricePriceTieredWithProration() + { + Cadence = PricePriceTieredWithProrationCadence.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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice value = new PricePriceGroupedWithMinMaxThresholds() + { + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice 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() + { + PricePrice value = new PricePriceCumulativeGroupedAllocation() + { + Cadence = PricePriceCumulativeGroupedAllocationCadence.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() + { + PricePrice 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() + { + PricePrice value = new PricePricePercent() + { + Cadence = PricePricePercentCadence.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() + { + PricePrice value = new PricePriceEventOutput() + { + Cadence = PricePriceEventOutputCadence.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 PricePriceBulkWithFiltersTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PricePriceBulkWithFilters + { + 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 = PricePriceBulkWithFiltersCadence.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", + }; + + PricePriceBulkWithFiltersBulkWithFiltersConfig 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 = + PricePriceBulkWithFiltersCadence.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; + PricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration 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 PricePriceBulkWithFilters + { + 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 = PricePriceBulkWithFiltersCadence.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 PricePriceBulkWithFilters + { + 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 = PricePriceBulkWithFiltersCadence.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); + + PricePriceBulkWithFiltersBulkWithFiltersConfig 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 = + PricePriceBulkWithFiltersCadence.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; + PricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration 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 PricePriceBulkWithFilters + { + 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 = PricePriceBulkWithFiltersCadence.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 PricePriceBulkWithFilters + { + 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 = PricePriceBulkWithFiltersCadence.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 PricePriceBulkWithFilters + { + 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 = PricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PricePriceBulkWithFilters + { + 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 = PricePriceBulkWithFiltersCadence.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 PricePriceBulkWithFilters + { + 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 = PricePriceBulkWithFiltersCadence.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 PricePriceBulkWithFilters + { + 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 = PricePriceBulkWithFiltersCadence.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", + }; + + PricePriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfig + { + 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 PricePriceBulkWithFiltersBulkWithFiltersConfig + { + 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 PricePriceBulkWithFiltersBulkWithFiltersConfig + { + 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 PricePriceBulkWithFiltersBulkWithFiltersConfig + { + 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 PricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + PricePriceBulkWithFiltersBulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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 PricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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 PricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + 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 PricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + PricePriceBulkWithFiltersBulkWithFiltersConfigFilter copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 PricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 PricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 PricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new TieredWithProrationConfig + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + 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]); - } + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new TieredWithProrationConfig + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + UnitAmount = "unit_amount", }; model.Validate(); } -} -public class TieredWithProrationConfigTierTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new TieredWithProrationConfigTier + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigTier { - TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", - }; - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + TierLowerBound = null, + }; - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Null(model.TierLowerBound); + Assert.True(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] - public void SerializationRoundtrip_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new TieredWithProrationConfigTier + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigTier { - TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", - }; - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + TierLowerBound = null, + }; - Assert.Equal(model, deserialized); + model.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void CopyConstructor_Works() { - var model = new TieredWithProrationConfigTier + var model = new PricePriceBulkWithFiltersBulkWithFiltersConfigTier { - TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, + PricePriceBulkWithFiltersBulkWithFiltersConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PricePriceBulkWithFiltersCadenceTest : TestBase +{ + [Theory] + [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; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + [Theory] + [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; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = new TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + 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); - model.Validate(); + Assert.Equal(value, deserialized); } } -public class TieredWithProrationConversionRateConfigTest : TestBase +public class PricePriceBulkWithFiltersConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - TieredWithProrationConversionRateConfig 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() { - TieredWithProrationConversionRateConfig value = + PricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -6393,16 +46781,18 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig 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); } @@ -6410,7 +46800,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig value = + PricePriceBulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -6426,32 +46816,29 @@ 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 PricePriceTieredWithProrationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceTieredWithProration { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = PricePriceTieredWithProrationCadence.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() @@ -6480,24 +46867,18 @@ public void FieldRoundtrip_Works() 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", - }; + ApiEnum expectedCadence = + PricePriceTieredWithProrationCadence.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"; + PricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -6506,7 +46887,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + PricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6527,17 +46908,15 @@ public void FieldRoundtrip_Works() 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(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -6549,6 +46928,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) @@ -6563,18 +46943,14 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceTieredWithProration { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = PricePriceTieredWithProrationCadence.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() @@ -6603,12 +46979,13 @@ public void SerializationRoundtrip_Works() 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 ); @@ -6619,18 +46996,14 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceTieredWithProration { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = PricePriceTieredWithProrationCadence.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() @@ -6659,31 +47032,25 @@ public void FieldRoundtripThroughSerialization_Works() 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); - ApiEnum expectedCadence = - GroupedWithMinMaxThresholdsCadence.Annual; - GroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + ApiEnum expectedCadence = + PricePriceTieredWithProrationCadence.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"; + PricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -6692,7 +47059,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + PricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6713,17 +47080,15 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -6738,6 +47103,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) @@ -6752,18 +47118,14 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceTieredWithProration { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = PricePriceTieredWithProrationCadence.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() @@ -6792,6 +47154,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6802,18 +47165,14 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceTieredWithProration { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = PricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; Assert.Null(model.BillableMetricID); @@ -6838,6 +47197,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); @@ -6847,18 +47208,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceTieredWithProration { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = PricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -6867,18 +47224,14 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceTieredWithProration { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = PricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -6891,6 +47244,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6917,6 +47271,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); @@ -6926,18 +47282,14 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new PricePriceTieredWithProration { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Cadence = PricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -6950,57 +47302,106 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePriceTieredWithProration + { + Cadence = PricePriceTieredWithProrationCadence.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", + }; + + PricePriceTieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } } -public class GroupedWithMinMaxThresholdsCadenceTest : TestBase +public class PricePriceTieredWithProrationCadenceTest : 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(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(GroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] - public void SerializationRoundtrip_Works(GroupedWithMinMaxThresholdsCadence 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< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -7009,59 +47410,54 @@ 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 PricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new PricePriceTieredWithProrationTieredWithProrationConfig { - 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 GroupedWithMinMaxThresholdsConfig + var model = new PricePriceTieredWithProrationTieredWithProrationConfig { - 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( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -7069,53 +47465,150 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new PricePriceTieredWithProrationTieredWithProrationConfig { - 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( - element, - 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"; + 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 GroupedWithMinMaxThresholdsConfig + var model = new PricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + PricePriceTieredWithProrationTieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class PricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PricePriceTieredWithProrationTieredWithProrationConfigTier + { + 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 PricePriceTieredWithProrationTieredWithProrationConfigTier + { + 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 PricePriceTieredWithProrationTieredWithProrationConfigTier + { + 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 PricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePriceTieredWithProrationTieredWithProrationConfigTier { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - model.Validate(); + PricePriceTieredWithProrationTieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); } } -public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class PricePriceTieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + PricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7127,7 +47620,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + PricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -7148,7 +47641,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + PricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7156,7 +47649,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7167,7 +47660,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + PricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -7184,7 +47677,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7193,20 +47686,20 @@ public void TieredSerializationRoundtripWorks() } } -public class CumulativeGroupedAllocationTest : TestBase +public class PricePriceGroupedWithMinMaxThresholdsTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.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", @@ -7238,22 +47731,24 @@ public void FieldRoundtrip_Works() 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", - }; + 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( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -7264,7 +47759,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + PricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7285,13 +47780,14 @@ public void FieldRoundtrip_Works() 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 + expectedGroupedWithMinMaxThresholdsConfig, + model.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); @@ -7307,6 +47803,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) @@ -7321,15 +47818,15 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.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", @@ -7361,12 +47858,13 @@ public void SerializationRoundtrip_Works() 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 ); @@ -7377,15 +47875,15 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.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", @@ -7417,29 +47915,31 @@ public void FieldRoundtripThroughSerialization_Works() 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); - ApiEnum expectedCadence = - CumulativeGroupedAllocationCadence.Annual; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + 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( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -7450,7 +47950,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + PricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7471,13 +47971,14 @@ public void FieldRoundtripThroughSerialization_Works() 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 + expectedGroupedWithMinMaxThresholdsConfig, + deserialized.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); @@ -7496,6 +47997,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) @@ -7510,15 +48012,15 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.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", @@ -7550,6 +48052,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7560,15 +48063,15 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.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", @@ -7596,6 +48099,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); @@ -7605,15 +48110,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.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", @@ -7625,15 +48130,15 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.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", @@ -7649,6 +48154,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7675,6 +48181,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); @@ -7684,15 +48192,15 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new PricePriceGroupedWithMinMaxThresholds { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.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", @@ -7708,57 +48216,110 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePriceGroupedWithMinMaxThresholds + { + Cadence = PricePriceGroupedWithMinMaxThresholdsCadence.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", + }; + + PricePriceGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } -public class CumulativeGroupedAllocationCadenceTest : TestBase +public class PricePriceGroupedWithMinMaxThresholdsCadenceTest : 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(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(CumulativeGroupedAllocationCadence.Annual)] - [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(CumulativeGroupedAllocationCadence.Monthly)] - [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(CumulativeGroupedAllocationCadence.OneTime)] - [InlineData(CumulativeGroupedAllocationCadence.Custom)] - public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence 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); @@ -7767,59 +48328,59 @@ 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 PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - 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 CumulativeGroupedAllocationConfig + var model = new PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - 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( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -7827,53 +48388,70 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", + var model = new PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { 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( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string 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 CumulativeGroupedAllocationConfig + var model = new PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } } -public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class PricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + PricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7885,7 +48463,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + PricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -7906,7 +48484,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + PricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7914,7 +48492,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7925,7 +48503,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + PricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -7942,7 +48520,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7951,16 +48529,22 @@ public void TieredSerializationRoundtripWorks() } } -public class MinimumTest : TestBase +public class PricePriceCumulativeGroupedAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Minimum + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = MinimumCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.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, @@ -7990,18 +48574,25 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum expectedCadence = MinimumCadence.Annual; + ApiEnum expectedCadence = + PricePriceCumulativeGroupedAllocationCadence.Annual; + PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - MinimumConfig 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; @@ -8011,7 +48602,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = + PricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8032,12 +48623,16 @@ public void FieldRoundtrip_Works() 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(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -8051,6 +48646,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) @@ -8065,11 +48661,17 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Minimum + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = MinimumCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.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, @@ -8099,12 +48701,16 @@ public void SerializationRoundtrip_Works() 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); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -8112,11 +48718,17 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Minimum + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = MinimumCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.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, @@ -8146,25 +48758,32 @@ public void FieldRoundtripThroughSerialization_Works() 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); - ApiEnum expectedCadence = MinimumCadence.Annual; + ApiEnum expectedCadence = + PricePriceCumulativeGroupedAllocationCadence.Annual; + PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - MinimumConfig 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; @@ -8174,7 +48793,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = + PricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8195,12 +48814,16 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -8217,6 +48840,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) @@ -8231,11 +48855,17 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Minimum + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = MinimumCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.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, @@ -8265,6 +48895,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8275,11 +48906,17 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Minimum + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = MinimumCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.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", }; @@ -8305,6 +48942,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); @@ -8314,11 +48953,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Minimum + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = MinimumCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.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", }; @@ -8328,11 +48973,17 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Minimum + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = MinimumCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.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, @@ -8346,6 +48997,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8372,6 +49024,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); @@ -8381,11 +49035,17 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Minimum + var model = new PricePriceCumulativeGroupedAllocation { - Cadence = MinimumCadence.Annual, + Cadence = PricePriceCumulativeGroupedAllocationCadence.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, @@ -8399,59 +49059,111 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePriceCumulativeGroupedAllocation + { + Cadence = PricePriceCumulativeGroupedAllocationCadence.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", + }; + + PricePriceCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } -public class MinimumCadenceTest : TestBase +public class PricePriceCumulativeGroupedAllocationCadenceTest : 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(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(MinimumCadence.Annual)] - [InlineData(MinimumCadence.SemiAnnual)] - [InlineData(MinimumCadence.Monthly)] - [InlineData(MinimumCadence.Quarterly)] - [InlineData(MinimumCadence.OneTime)] - [InlineData(MinimumCadence.Custom)] - public void SerializationRoundtrip_Works(MinimumCadence rawValue) + [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>( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } @@ -8459,168 +49171,174 @@ public void SerializationRoundtrip_Works(MinimumCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class MinimumConfigTest : TestBase +public class PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest : 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); + var model = new PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] - public void Validation_Works() + public void SerializationRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - model.Validate(); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + public void FieldRoundtripThroughSerialization_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - model.Validate(); + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void Validation_Works() { - var model = new MinimumConfig + var model = new PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - 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", }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() + public void CopyConstructor_Works() { - var model = new MinimumConfig + var model = new PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - 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(); + PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); } } -public class MinimumConversionRateConfigTest : TestBase +public class PricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + PricePriceCumulativeGroupedAllocationConversionRateConfig 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, - }, - ] - ), - }; + PricePriceCumulativeGroupedAllocationConversionRateConfig 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"), - }; + PricePriceCumulativeGroupedAllocationConversionRateConfig 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); } @@ -8628,38 +49346,40 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + PricePriceCumulativeGroupedAllocationConversionRateConfig 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 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), @@ -8691,15 +49411,16 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, 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() @@ -8708,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, @@ -8729,6 +49450,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"; @@ -8748,6 +49470,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) @@ -8762,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), @@ -8796,12 +49519,16 @@ public void SerializationRoundtrip_Works() 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); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -8809,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), @@ -8843,22 +49570,23 @@ public void FieldRoundtripThroughSerialization_Works() 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); - 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() @@ -8867,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, @@ -8888,6 +49616,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"; @@ -8910,6 +49639,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) @@ -8924,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), @@ -8958,6 +49688,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8968,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), @@ -8998,6 +49729,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); @@ -9007,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), @@ -9021,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), @@ -9039,6 +49772,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9065,6 +49799,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); @@ -9074,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), @@ -9092,34 +49828,82 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePricePercent + { + Cadence = PricePricePercentCadence.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", + }; + + 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 ); @@ -9129,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 ); @@ -9152,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 ); @@ -9166,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; @@ -9181,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 ); @@ -9195,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 ); @@ -9212,18 +49996,28 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new PercentConfig { Percent = 0 }; + var model = new PricePricePercentPercentConfig { Percent = 0 }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePricePercentPercentConfig { Percent = 0 }; - model.Validate(); + 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"), @@ -9234,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( @@ -9254,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 ); @@ -9271,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( @@ -9286,7 +50080,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9295,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", @@ -9339,12 +50133,14 @@ public void FieldRoundtrip_Works() 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() + ApiEnum expectedCadence = + PricePriceEventOutputCadence.Annual; + PricePriceEventOutputEventOutputConfig expectedEventOutputConfig = new() { UnitRatingKey = "x", DefaultUnitRate = "default_unit_rate", @@ -9361,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, @@ -9382,6 +50178,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"; @@ -9401,6 +50198,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) @@ -9415,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", @@ -9454,12 +50252,13 @@ public void SerializationRoundtrip_Works() 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 ); @@ -9470,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", @@ -9509,19 +50308,21 @@ public void FieldRoundtripThroughSerialization_Works() 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); - ApiEnum expectedCadence = EventOutputCadence.Annual; - EventOutputConfig expectedEventOutputConfig = new() + ApiEnum expectedCadence = + PricePriceEventOutputCadence.Annual; + PricePriceEventOutputEventOutputConfig expectedEventOutputConfig = new() { UnitRatingKey = "x", DefaultUnitRate = "default_unit_rate", @@ -9538,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, @@ -9559,6 +50360,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"; @@ -9581,6 +50383,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) @@ -9595,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", @@ -9634,6 +50437,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9644,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", @@ -9679,6 +50483,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); @@ -9688,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", @@ -9707,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", @@ -9730,6 +50536,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9756,6 +50563,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); @@ -9765,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", @@ -9788,34 +50597,87 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePriceEventOutput + { + Cadence = PricePriceEventOutputCadence.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", + }; + + 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 ); @@ -9825,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); } @@ -9848,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", @@ -9886,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", @@ -9894,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 ); @@ -9905,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", @@ -9913,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 ); @@ -9931,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", @@ -9944,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")); @@ -9955,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(); } @@ -9963,7 +50823,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new EventOutputConfig + var model = new PricePriceEventOutputEventOutputConfig { UnitRatingKey = "x", @@ -9980,7 +50840,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new EventOutputConfig + var model = new PricePriceEventOutputEventOutputConfig { UnitRatingKey = "x", @@ -9990,51 +50850,69 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PricePriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + 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 ); @@ -10045,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 ); @@ -10379,6 +51258,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 @@ -10818,6 +51730,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/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/PlanListPageResponseTest.cs b/src/Orb.Tests/Models/Plans/PlanListPageResponseTest.cs index f963a44d7..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() @@ -1767,4 +1809,305 @@ 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + ], + 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/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/PlanTest.cs b/src/Orb.Tests/Models/Plans/PlanTest.cs index ff7d72d34..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() @@ -1780,6 +1822,297 @@ 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + ], + 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 +2487,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 +2894,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 +3099,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 +3230,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/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/PriceIntervalTest.cs b/src/Orb.Tests/Models/PriceIntervalTest.cs index 6007a85c7..575eeb629 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,9 +138,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }; string expectedID = "id"; @@ -203,6 +214,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -266,9 +278,19 @@ 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"]; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillingCycleDay, model.BillingCycleDay); @@ -297,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] @@ -361,6 +391,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -428,9 +459,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -504,6 +545,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -571,9 +613,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -644,6 +696,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -707,9 +760,19 @@ 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"]; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillingCycleDay, deserialized.BillingCycleDay); @@ -741,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] @@ -805,6 +881,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -872,11 +949,753 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }; model.Validate(); } + + [Fact] + 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 + { + 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"], + }; + + 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/PriceTest.cs b/src/Orb.Tests/Models/PriceTest.cs index f7a6bc8c1..5a3cb86ad 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() @@ -2951,6 +3120,7 @@ public void ScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -2959,6 +3129,12 @@ public void ScalableMatrixWithUnitPricingValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3007,6 +3183,7 @@ public void ScalableMatrixWithTieredPricingValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3088,6 +3265,12 @@ public void ScalableMatrixWithTieredPricingValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3136,6 +3319,7 @@ public void CumulativeGroupedBulkValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -3211,6 +3395,12 @@ public void CumulativeGroupedBulkValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3259,6 +3449,7 @@ public void CumulativeGroupedAllocationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -3328,116 +3519,11 @@ public void CumulativeGroupedAllocationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, - }; - value.Validate(); - } - - [Fact] - public void MinimumValidationWorks() - { - 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() + 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", - 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", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, }; value.Validate(); @@ -3487,6 +3573,7 @@ public void MinimumCompositeValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3550,6 +3637,12 @@ public void MinimumCompositeValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3598,6 +3691,7 @@ public void PercentValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3661,6 +3755,12 @@ public void PercentValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3709,6 +3809,7 @@ public void EventOutputValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3777,6 +3878,12 @@ public void EventOutputValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3825,6 +3932,7 @@ public void UnitSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3888,6 +3996,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); @@ -3939,6 +4053,7 @@ public void TieredSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4014,6 +4129,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); @@ -4066,6 +4187,7 @@ public void BulkSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4128,6 +4250,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); @@ -4188,6 +4316,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4250,6 +4379,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); @@ -4301,6 +4436,7 @@ public void PackageSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4364,6 +4500,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); @@ -4415,6 +4557,7 @@ public void MatrixSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4483,6 +4626,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); @@ -4534,6 +4683,7 @@ public void ThresholdTotalAmountSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4605,6 +4755,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); @@ -4656,6 +4812,7 @@ public void TieredPackageSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4727,6 +4884,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); @@ -4778,6 +4941,7 @@ public void TieredWithMinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4860,6 +5024,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); @@ -4911,6 +5081,7 @@ public void GroupedTieredSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4982,6 +5153,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); @@ -5033,6 +5210,7 @@ public void TieredPackageWithMinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5114,6 +5292,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); @@ -5165,6 +5349,7 @@ public void PackageWithAllocationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5233,6 +5418,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); @@ -5284,6 +5475,7 @@ public void UnitWithPercentSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5347,6 +5539,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); @@ -5398,6 +5596,7 @@ public void MatrixWithAllocationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5467,6 +5666,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); @@ -5518,6 +5723,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5583,6 +5789,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); @@ -5634,6 +5846,7 @@ public void UnitWithProrationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5697,6 +5910,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); @@ -5748,6 +5967,7 @@ public void GroupedAllocationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5816,6 +6036,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); @@ -5873,6 +6099,7 @@ public void BulkWithProrationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5935,6 +6162,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); @@ -5986,6 +6219,7 @@ public void GroupedWithProratedMinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6054,6 +6288,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); @@ -6105,6 +6345,7 @@ public void GroupedWithMeteredMinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6182,6 +6423,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); @@ -6233,6 +6480,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6302,6 +6550,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); @@ -6353,6 +6607,7 @@ public void MatrixWithDisplayNameSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6428,6 +6683,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); @@ -6479,6 +6740,7 @@ public void GroupedTieredPackageSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6551,6 +6813,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); @@ -6602,6 +6870,7 @@ public void MaxGroupTieredPackageSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6674,6 +6943,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); @@ -6725,6 +7000,7 @@ public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6795,6 +7071,7 @@ public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -6803,6 +7080,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); @@ -6854,6 +7137,7 @@ public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6935,6 +7219,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); @@ -6986,6 +7276,7 @@ public void CumulativeGroupedBulkSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -7061,6 +7352,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); @@ -7112,6 +7409,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -7181,6 +7479,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); @@ -7189,21 +7493,21 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void MinimumCompositeSerializationRoundtripWorks() { - 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"], }, ], @@ -7232,6 +7536,7 @@ public void MinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7285,16 +7590,22 @@ public void MinimumSerializationRoundtripWorks() 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() { 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); @@ -7303,21 +7614,21 @@ public void MinimumSerializationRoundtripWorks() } [Fact] - public void MinimumCompositeSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { - 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"], }, ], @@ -7346,6 +7657,7 @@ public void MinimumCompositeSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7399,16 +7711,22 @@ public void MinimumCompositeSerializationRoundtripWorks() 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() { 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); @@ -7417,21 +7735,21 @@ public void MinimumCompositeSerializationRoundtripWorks() } [Fact] - public void PercentSerializationRoundtripWorks() + public void EventOutputSerializationRoundtripWorks() { - 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"], }, ], @@ -7460,6 +7778,7 @@ public void PercentSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7478,6 +7797,12 @@ public void PercentSerializationRoundtripWorks() ], 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 }, @@ -7514,38 +7839,46 @@ public void PercentSerializationRoundtripWorks() }, MinimumAmount = "minimum_amount", Name = "name", - PercentConfig = new(0), PlanPhaseOrder = 0, - PriceType = PercentPriceType.UsagePrice, + PriceType = EventOutputPriceType.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(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } +} +public class UnitTest : TestBase +{ [Fact] - public void EventOutputSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Price value = new EventOutput() + var model = 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"], }, ], @@ -7574,6 +7907,7 @@ public void EventOutputSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7592,12 +7926,6 @@ public void EventOutputSerializationRoundtripWorks() ], 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 }, @@ -7635,25 +7963,185 @@ public void EventOutputSerializationRoundtripWorks() 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", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + string expectedID = "id"; + BillableMetricTiny expectedBillableMetric = new("id"); + BillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }; + ApiEnum expectedBillingMode = BillingMode.InAdvance; + ApiEnum expectedCadence = UnitCadence.OneTime; + List expectedCompositePriceFilters = + [ + new() + { + Field = CompositePriceFilterField.PriceID, + Operator = CompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ]; + double expectedConversionRate = 0; + UnitConversionRateConfig 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"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit"); + string expectedName = "name"; + long expectedPlanPhaseOrder = 0; + ApiEnum expectedPriceType = UnitPriceType.UsagePrice; + string expectedReplacesPriceID = "replaces_price_id"; + UnitConfig expectedUnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }; + DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + 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); + 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.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(expectedUnitConfig, model.UnitConfig); + Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } -} -public class UnitTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void SerializationRoundtrip_Works() { var model = new Unit { @@ -7696,6 +8184,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7759,267 +8248,11 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, - }; - - string expectedID = "id"; - BillableMetricTiny expectedBillableMetric = new("id"); - BillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = DurationUnit.Day, - }; - ApiEnum expectedBillingMode = BillingMode.InAdvance; - ApiEnum expectedCadence = UnitCadence.OneTime; - List expectedCompositePriceFilters = - [ - new() - { - Field = CompositePriceFilterField.PriceID, - Operator = CompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ]; - double expectedConversionRate = 0; - UnitConversionRateConfig 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"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("unit"); - string expectedName = "name"; - long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = UnitPriceType.UsagePrice; - string expectedReplacesPriceID = "replaces_price_id"; - UnitConfig expectedUnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }; - 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.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(expectedUnitConfig, model.UnitConfig); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - } - - [Fact] - public void SerializationRoundtrip_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() + LicenseType = 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", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, }; @@ -8073,6 +8306,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8136,6 +8370,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); @@ -8185,6 +8425,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -8253,6 +8494,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); @@ -8296,6 +8543,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -8342,6 +8590,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8405,6 +8654,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -8454,6 +8709,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8516,6 +8772,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] @@ -8562,6 +8820,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8669,6 +8928,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8729,10 +8989,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] @@ -8779,6 +9042,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8839,10 +9103,132 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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", + }, + }; + + Unit copied = new(model); + + Assert.Equal(model, copied); + } } public class BillingModeTest : TestBase @@ -9059,6 +9445,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 @@ -9318,6 +9719,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] @@ -9364,6 +9860,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -9439,6 +9936,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -9485,6 +9988,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -9565,6 +10069,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); @@ -9605,6 +10115,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] @@ -9651,6 +10162,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -9726,6 +10238,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); @@ -9778,6 +10296,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -9853,6 +10372,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); @@ -9903,6 +10428,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -9983,6 +10509,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); @@ -10026,6 +10558,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -10072,6 +10605,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10147,6 +10681,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -10196,6 +10736,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10270,6 +10811,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] @@ -10316,6 +10859,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10435,6 +10979,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10507,10 +11052,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] @@ -10557,6 +11105,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10629,10 +11178,144 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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, + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + Tiered copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredBillingModeTest : TestBase @@ -10849,6 +11532,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 @@ -11106,6 +11804,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] @@ -11153,6 +11946,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11215,6 +12009,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -11263,6 +12063,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -11330,6 +12131,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); @@ -11370,6 +12177,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] @@ -11417,6 +12225,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11479,6 +12288,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); @@ -11532,6 +12347,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11594,6 +12410,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); @@ -11646,6 +12468,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -11713,6 +12536,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); @@ -11756,6 +12585,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -11803,6 +12633,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11865,6 +12696,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -11915,6 +12752,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11976,6 +12814,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] @@ -12023,6 +12863,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12130,6 +12971,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12189,10 +13031,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] @@ -12240,6 +13085,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12299,10 +13145,132 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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 = BulkPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + Bulk copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkBillingModeTest : TestBase @@ -12519,6 +13487,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 @@ -12776,6 +13759,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] @@ -12831,6 +13909,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12893,6 +13972,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -12949,6 +14034,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -13017,6 +14103,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); @@ -13057,6 +14149,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] @@ -13112,6 +14205,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13174,6 +14268,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); @@ -13238,6 +14338,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13300,6 +14401,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); @@ -13363,6 +14470,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -13431,6 +14539,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); @@ -13474,6 +14588,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -13529,6 +14644,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13591,6 +14707,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -13649,6 +14771,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13710,6 +14833,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] @@ -13765,6 +14890,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13880,6 +15006,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13939,10 +15066,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] @@ -13998,6 +15128,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -14057,10 +15188,140 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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 = BulkWithFiltersPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + BulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithFiltersBillingModeTest : TestBase @@ -14237,6 +15498,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 @@ -14293,6 +15572,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 @@ -14409,6 +15698,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 @@ -14567,6 +15870,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 @@ -14820,6 +16138,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] @@ -14866,6 +16279,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -14929,6 +16343,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -14975,6 +16395,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -15047,6 +16468,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); @@ -15087,6 +16514,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] @@ -15133,6 +16561,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15196,6 +16625,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); @@ -15248,6 +16683,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15311,6 +16747,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); @@ -15364,6 +16806,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -15436,6 +16879,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); @@ -15479,6 +16928,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -15525,6 +16975,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15588,6 +17039,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -15637,6 +17094,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15699,6 +17157,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] @@ -15745,6 +17205,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15852,6 +17313,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15912,10 +17374,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] @@ -15962,6 +17427,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -16022,10 +17488,132 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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", + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + Package copied = new(model); + + Assert.Equal(model, copied); + } } public class PackageBillingModeTest : TestBase @@ -16242,6 +17830,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 @@ -16497,6 +18100,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] @@ -16543,6 +18241,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -16611,6 +18310,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -16657,6 +18362,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -16730,6 +18436,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); @@ -16770,6 +18482,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] @@ -16816,6 +18529,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -16884,6 +18598,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); @@ -16936,6 +18656,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17004,6 +18725,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); @@ -17054,6 +18781,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -17127,6 +18855,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); @@ -17170,6 +18904,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -17216,6 +18951,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17284,6 +19020,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -17333,6 +19075,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17400,6 +19143,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] @@ -17446,6 +19191,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17558,6 +19304,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17623,10 +19370,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] @@ -17673,6 +19423,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17738,10 +19489,137 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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" }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + Matrix copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixBillingModeTest : TestBase @@ -17958,6 +19836,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 @@ -18215,6 +20108,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] @@ -18261,6 +20249,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -18332,6 +20321,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -18380,6 +20375,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -18457,6 +20453,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); @@ -18497,6 +20499,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] @@ -18543,6 +20546,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -18614,6 +20618,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); @@ -18669,6 +20679,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -18740,6 +20751,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); @@ -18795,6 +20812,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -18872,6 +20890,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); @@ -18915,6 +20939,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -18961,6 +20986,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19032,6 +21058,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -19081,6 +21113,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19151,6 +21184,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] @@ -19197,6 +21232,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19312,6 +21348,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19380,10 +21417,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] @@ -19430,6 +21470,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19498,10 +21539,140 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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 = 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + ThresholdTotalAmount copied = new(model); + + Assert.Equal(model, copied); + } } public class ThresholdTotalAmountBillingModeTest : TestBase @@ -19716,6 +21887,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 @@ -20139,6 +22325,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 @@ -20213,6 +22417,115 @@ 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 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 @@ -20261,6 +22574,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -20332,6 +22646,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -20379,6 +22699,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -20456,6 +22777,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); @@ -20496,6 +22823,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] @@ -20542,6 +22870,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -20613,6 +22942,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); @@ -20668,6 +23003,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -20739,6 +23075,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); @@ -20793,6 +23135,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -20870,6 +23213,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); @@ -20913,6 +23262,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -20959,6 +23309,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21030,6 +23381,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -21079,6 +23436,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21149,6 +23507,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] @@ -21195,6 +23555,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21310,6 +23671,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21378,10 +23740,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] @@ -21428,6 +23793,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21496,10 +23862,140 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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 = 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + TieredPackage copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredPackageBillingModeTest : TestBase @@ -21716,6 +24212,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 @@ -22071,6 +24582,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 @@ -22143,6 +24672,115 @@ 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 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 @@ -22191,6 +24829,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -22273,6 +24912,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -22321,6 +24966,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -22409,6 +25055,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); @@ -22449,6 +25101,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] @@ -22495,6 +25148,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -22577,6 +25231,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); @@ -22632,6 +25292,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -22714,6 +25375,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); @@ -22769,6 +25436,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -22857,6 +25525,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); @@ -22900,6 +25574,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -22946,6 +25621,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -23028,6 +25704,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -23077,6 +25759,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -23158,6 +25841,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] @@ -23204,6 +25889,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -23330,6 +26016,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -23409,10 +26096,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] @@ -23459,6 +26149,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -23538,10 +26229,151 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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, + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + TieredWithMinimum copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithMinimumBillingModeTest : TestBase @@ -23756,6 +26588,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 @@ -24293,6 +27140,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 @@ -24373,6 +27249,116 @@ 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 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 @@ -24421,6 +27407,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -24492,6 +27479,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -24539,6 +27532,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -24616,6 +27610,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); @@ -24656,6 +27656,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] @@ -24702,6 +27703,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -24773,6 +27775,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); @@ -24828,6 +27836,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -24899,6 +27908,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); @@ -24953,6 +27968,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -25030,6 +28046,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); @@ -25073,6 +28095,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -25119,6 +28142,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25190,6 +28214,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -25239,6 +28269,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25309,6 +28340,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] @@ -25355,6 +28388,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25470,6 +28504,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25538,10 +28573,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] @@ -25588,6 +28626,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25656,10 +28695,140 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + GroupedTiered copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredBillingModeTest : TestBase @@ -25876,6 +29045,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 @@ -26171,6 +29355,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 @@ -26243,6 +29445,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 @@ -26305,6 +29521,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] @@ -26351,6 +29662,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -26432,6 +29744,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -26480,6 +29798,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -26570,6 +29889,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); @@ -26610,6 +29935,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] @@ -26656,6 +29982,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -26737,6 +30064,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); @@ -26792,6 +30125,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -26873,6 +30207,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); @@ -26928,6 +30268,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -27018,6 +30359,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); @@ -27064,6 +30411,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -27110,6 +30458,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -27191,6 +30540,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -27240,6 +30595,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -27320,6 +30676,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] @@ -27366,6 +30724,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -27491,6 +30850,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -27569,10 +30929,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] @@ -27619,6 +30982,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -27697,10 +31061,150 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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 = 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + TieredPackageWithMinimum copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredPackageWithMinimumBillingModeTest : TestBase @@ -27911,6 +31415,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 @@ -28330,6 +31849,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 @@ -28412,6 +31959,116 @@ 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 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 @@ -28460,6 +32117,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -28528,6 +32186,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -28576,6 +32240,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -28652,6 +32317,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); @@ -28692,6 +32363,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] @@ -28738,6 +32410,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -28806,6 +32479,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); @@ -28861,6 +32540,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -28929,6 +32609,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); @@ -28984,6 +32670,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -29060,6 +32747,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); @@ -29103,6 +32796,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -29149,6 +32843,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29217,6 +32912,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -29266,6 +32967,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29333,6 +33035,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] @@ -29379,6 +33083,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29491,6 +33196,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29556,10 +33262,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] @@ -29606,6 +33315,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29671,10 +33381,137 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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", + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + PackageWithAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class PackageWithAllocationBillingModeTest : TestBase @@ -29887,6 +33724,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 @@ -30164,6 +34016,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 @@ -30224,6 +34091,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] @@ -30270,6 +34232,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30333,6 +34296,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -30380,6 +34349,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -30453,6 +34423,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); @@ -30493,6 +34469,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] @@ -30539,6 +34516,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30602,6 +34580,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); @@ -30657,6 +34641,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30720,6 +34705,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); @@ -30774,6 +34765,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -30847,6 +34839,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); @@ -30890,6 +34888,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -30936,6 +34935,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30999,228 +34999,19 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_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() + 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 = UnitWithPercentPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, - }; - - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_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", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = UnitWithPercentPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new UnitWithPercent { @@ -31263,6 +35054,226 @@ 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 = UnitWithPercentPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + }; + + 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 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"], + }, + ], + 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 = UnitWithPercentPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_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"], + }, + ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -31323,10 +35334,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] @@ -31373,6 +35387,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -31433,10 +35448,132 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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 = UnitWithPercentPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + UnitWithPercent copied = new(model); + + Assert.Equal(model, copied); + } } public class UnitWithPercentBillingModeTest : TestBase @@ -31653,6 +35790,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 @@ -31976,6 +36128,115 @@ 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 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 @@ -32024,6 +36285,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32093,6 +36355,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -32141,6 +36409,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -32216,6 +36485,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); @@ -32256,6 +36531,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] @@ -32302,6 +36578,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32371,6 +36648,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); @@ -32426,6 +36709,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32495,6 +36779,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); @@ -32550,6 +36840,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -32625,6 +36916,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); @@ -32668,6 +36965,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -32714,6 +37012,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32783,6 +37082,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -32832,6 +37137,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32900,6 +37206,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] @@ -32946,6 +37254,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -33059,6 +37368,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -33125,10 +37435,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] @@ -33175,6 +37488,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -33241,10 +37555,138 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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" }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + MatrixWithAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithAllocationBillingModeTest : TestBase @@ -33459,6 +37901,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 @@ -33712,6 +38169,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] @@ -33758,6 +38310,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -33823,6 +38376,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -33871,6 +38430,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -33942,6 +38502,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); @@ -33982,6 +38548,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] @@ -34028,6 +38595,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34093,6 +38661,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); @@ -34148,6 +38722,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34213,6 +38788,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); @@ -34268,6 +38849,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -34339,6 +38921,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); @@ -34382,6 +38970,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -34428,6 +39017,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34493,6 +39083,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -34542,6 +39138,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34606,6 +39203,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] @@ -34652,6 +39251,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34761,6 +39361,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34823,10 +39424,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] @@ -34873,6 +39477,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34935,10 +39540,134 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ), DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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 = 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + TieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationBillingModeTest : TestBase @@ -35153,6 +39882,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 @@ -35482,6 +40226,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 @@ -35556,6 +40313,115 @@ 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 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 @@ -35604,6 +40470,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -35667,6 +40534,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -35715,6 +40588,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -35786,6 +40660,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); @@ -35826,6 +40706,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] @@ -35872,6 +40753,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -35935,6 +40817,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); @@ -35990,6 +40878,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36053,6 +40942,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); @@ -36108,6 +41003,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -36179,6 +41075,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); @@ -36222,6 +41124,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -36268,6 +41171,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36331,6 +41235,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -36380,6 +41290,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36442,6 +41353,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] @@ -36488,6 +41401,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36595,6 +41509,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36655,10 +41570,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] @@ -36705,6 +41623,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36765,10 +41684,132 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() UnitWithProrationConfig = new("unit_amount"), DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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 = UnitWithProrationPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + UnitWithProrationConfig = new("unit_amount"), + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + UnitWithProration copied = new(model); + + Assert.Equal(model, copied); + } } public class UnitWithProrationBillingModeTest : TestBase @@ -36983,6 +42024,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 @@ -37286,6 +42342,111 @@ 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 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 @@ -37334,6 +42495,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -37402,6 +42564,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -37450,6 +42618,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -37524,6 +42693,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); @@ -37564,6 +42739,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] @@ -37610,6 +42786,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -37678,6 +42855,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); @@ -37733,6 +42916,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -37801,6 +42985,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); @@ -37856,6 +43046,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -37930,6 +43121,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); @@ -37973,6 +43170,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -38019,6 +43217,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38087,6 +43286,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -38136,6 +43341,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38203,6 +43409,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] @@ -38249,6 +43457,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38361,6 +43570,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38426,10 +43636,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] @@ -38476,6 +43689,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38541,10 +43755,137 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + GroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedAllocationBillingModeTest : TestBase @@ -38759,6 +44100,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 @@ -39030,6 +44386,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 @@ -39092,6 +44463,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] @@ -39144,6 +44610,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -39206,6 +44673,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -39260,6 +44733,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -39328,6 +44802,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); @@ -39368,6 +44848,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] @@ -39420,6 +44901,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -39482,6 +44964,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); @@ -39543,6 +45031,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -39605,6 +45094,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); @@ -39666,6 +45161,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -39734,6 +45230,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); @@ -39777,6 +45279,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -39829,6 +45332,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -39891,6 +45395,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -39946,6 +45456,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40007,6 +45518,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] @@ -40059,6 +45572,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40171,6 +45685,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40230,10 +45745,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] @@ -40286,6 +45804,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40345,10 +45864,137 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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 = BulkWithProrationPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + BulkWithProration copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithProrationBillingModeTest : TestBase @@ -40501,6 +46147,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 @@ -40617,6 +46280,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 @@ -40775,6 +46452,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 @@ -41028,6 +46720,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] @@ -41074,6 +46861,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -41142,6 +46930,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -41190,6 +46984,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -41267,6 +47062,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); @@ -41310,6 +47111,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] @@ -41356,6 +47158,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -41424,6 +47227,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); @@ -41479,6 +47288,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -41547,6 +47357,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); @@ -41602,6 +47418,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -41679,6 +47496,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); @@ -41725,6 +47548,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -41771,6 +47595,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -41839,238 +47664,19 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_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() + 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, - 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", - }; - - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_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", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = GroupedWithProratedMinimumPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new GroupedWithProratedMinimum { @@ -42113,6 +47719,236 @@ 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, + 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", + }; + + 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 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"], + }, + ], + 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, + 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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_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"], + }, + ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -42178,10 +48014,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] @@ -42228,6 +48067,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -42293,10 +48133,137 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + GroupedWithProratedMinimum copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithProratedMinimumBillingModeTest : TestBase @@ -42509,6 +48476,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 @@ -42790,6 +48772,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 @@ -42848,6 +48845,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] @@ -42894,6 +48986,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -42971,6 +49064,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -43019,6 +49118,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -43105,6 +49205,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); @@ -43148,6 +49254,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] @@ -43194,6 +49301,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -43271,6 +49379,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); @@ -43326,6 +49440,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -43403,6 +49518,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); @@ -43458,6 +49579,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -43544,6 +49666,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); @@ -43590,6 +49718,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -43636,6 +49765,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -43713,256 +49843,19 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_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", - }; - - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_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() + LicenseType = 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", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = GroupedWithMeteredMinimumPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new GroupedWithMeteredMinimum { @@ -44005,6 +49898,254 @@ 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, + 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", + }; + + 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 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"], + }, + ], + 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, + 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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_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"], + }, + ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -44079,10 +50220,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] @@ -44129,6 +50273,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -44203,10 +50348,146 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + GroupedWithMeteredMinimum copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMeteredMinimumBillingModeTest : TestBase @@ -44419,6 +50700,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 @@ -44762,6 +51058,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 @@ -44836,6 +51153,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 @@ -44910,6 +51241,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 @@ -44970,6 +51315,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] @@ -45016,6 +51456,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45085,6 +51526,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -45133,6 +51580,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -45210,6 +51658,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); @@ -45253,6 +51707,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] @@ -45299,6 +51754,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45368,6 +51824,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); @@ -45423,6 +51885,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45492,6 +51955,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); @@ -45547,6 +52016,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -45624,6 +52094,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); @@ -45670,6 +52146,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -45716,6 +52193,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45785,6 +52263,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -45834,6 +52318,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45902,6 +52387,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] @@ -45948,6 +52435,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -46061,6 +52549,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -46127,10 +52616,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] @@ -46177,6 +52669,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -46243,10 +52736,138 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsBillingModeTest : TestBase @@ -46459,6 +53080,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 @@ -46746,6 +53382,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 @@ -46804,6 +53456,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] @@ -46850,6 +53597,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -46925,6 +53673,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -46973,6 +53727,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -47056,6 +53811,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); @@ -47096,6 +53857,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] @@ -47142,6 +53904,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47217,6 +53980,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); @@ -47272,6 +54041,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47347,6 +54117,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); @@ -47402,6 +54178,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -47485,6 +54262,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); @@ -47528,6 +54311,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -47574,6 +54358,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47649,6 +54434,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -47698,6 +54489,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47772,6 +54564,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] @@ -47818,6 +54612,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47937,6 +54732,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -48009,10 +54805,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] @@ -48059,6 +54858,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -48131,10 +54931,144 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + MatrixWithDisplayName copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithDisplayNameBillingModeTest : TestBase @@ -48347,6 +55281,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 @@ -48672,6 +55621,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 @@ -48754,6 +55725,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 @@ -48814,6 +55800,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] @@ -48860,6 +55941,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -48932,6 +56014,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -48980,6 +56068,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -49058,6 +56147,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); @@ -49098,6 +56193,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] @@ -49144,6 +56240,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49216,6 +56313,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); @@ -49271,6 +56374,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49343,6 +56447,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); @@ -49398,6 +56508,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -49476,6 +56587,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); @@ -49519,6 +56636,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -49565,6 +56683,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49637,6 +56756,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -49686,6 +56811,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49757,6 +56883,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] @@ -49803,6 +56931,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49919,6 +57048,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49988,10 +57118,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] @@ -50038,6 +57171,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -50107,10 +57241,141 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + GroupedTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredPackageBillingModeTest : TestBase @@ -50325,6 +57590,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 @@ -50632,6 +57912,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 @@ -50706,6 +58005,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 @@ -50766,6 +58079,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] @@ -50812,6 +58220,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -50884,6 +58293,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -50932,6 +58347,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -51012,6 +58428,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); @@ -51052,6 +58474,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] @@ -51098,6 +58521,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51170,6 +58594,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); @@ -51225,6 +58655,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51297,6 +58728,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); @@ -51352,6 +58789,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -51432,6 +58870,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); @@ -51475,6 +58919,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -51521,6 +58966,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51593,6 +59039,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -51642,6 +59094,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51713,6 +59166,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] @@ -51759,6 +59214,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51875,6 +59331,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51944,10 +59401,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] @@ -51994,6 +59454,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -52063,10 +59524,141 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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" }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + MaxGroupTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } } public class MaxGroupTieredPackageBillingModeTest : TestBase @@ -52279,6 +59871,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 @@ -52588,6 +60195,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 @@ -52662,6 +60288,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 @@ -52722,6 +60362,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] @@ -52768,6 +60503,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -52838,6 +60574,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -52846,6 +60583,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -52894,6 +60637,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -52973,6 +60717,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -52981,6 +60726,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); @@ -53024,6 +60775,7 @@ public void FieldRoundtrip_Works() model.ScalableMatrixWithUnitPricingConfig ); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -53070,6 +60822,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53140,6 +60893,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -53148,6 +60902,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); @@ -53203,6 +60963,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53273,6 +61034,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -53281,6 +61043,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); @@ -53336,6 +61104,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -53415,6 +61184,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -53423,6 +61193,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); @@ -53469,6 +61245,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -53515,6 +61292,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53585,6 +61363,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -53593,6 +61372,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -53642,6 +61427,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53712,6 +61498,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -53719,6 +61506,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] @@ -53765,6 +61554,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53835,6 +61625,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -53887,6 +61678,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53957,15 +61749,19 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, 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] @@ -54012,6 +61808,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -54082,15 +61879,154 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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 = 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", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + ScalableMatrixWithUnitPricing copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithUnitPricingBillingModeTest : TestBase @@ -54305,6 +62241,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 @@ -54582,6 +62533,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -54597,6 +62549,7 @@ public void FieldRoundtrip_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -54607,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); } @@ -54627,6 +62581,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -54657,6 +62612,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -54680,6 +62636,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -54690,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); } @@ -54710,6 +62668,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -54735,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); @@ -54779,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); @@ -54806,12 +62770,39 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ], UnitPrice = "unit_price", + GroupingKey = null, Prorate = null, SecondDimension = null, }; 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", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorTest @@ -54957,6 +62948,118 @@ 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 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 @@ -55005,6 +63108,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55086,6 +63190,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -55134,6 +63244,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -55224,6 +63335,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); @@ -55267,6 +63384,7 @@ public void FieldRoundtrip_Works() model.ScalableMatrixWithTieredPricingConfig ); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -55313,6 +63431,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55394,6 +63513,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); @@ -55449,6 +63574,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55530,6 +63656,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); @@ -55585,6 +63717,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -55675,6 +63808,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); @@ -55721,6 +63860,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -55767,6 +63907,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55848,6 +63989,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -55897,6 +64044,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55977,6 +64125,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] @@ -56023,6 +64173,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -56148,6 +64299,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -56226,10 +64378,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] @@ -56276,6 +64431,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -56354,10 +64510,150 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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", + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + ScalableMatrixWithTieredPricing copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithTieredPricingBillingModeTest : TestBase @@ -56572,6 +64868,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 @@ -57117,6 +65428,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 @@ -57262,6 +65601,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 @@ -57336,6 +65692,117 @@ 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 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 @@ -57384,6 +65851,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -57459,6 +65927,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -57507,6 +65981,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; CumulativeGroupedBulkCumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = new() { @@ -57590,6 +66065,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); @@ -57630,6 +66111,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] @@ -57676,6 +66158,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -57751,6 +66234,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); @@ -57806,6 +66295,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -57881,6 +66371,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); @@ -57936,6 +66432,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; CumulativeGroupedBulkCumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = new() { @@ -58019,6 +66516,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); @@ -58062,6 +66565,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -58108,6 +66612,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -58183,6 +66688,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -58232,6 +66743,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -58306,6 +66818,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] @@ -58352,6 +66866,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -58471,6 +66986,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -58543,10 +67059,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] @@ -58593,6 +67112,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -58665,10 +67185,144 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + CumulativeGroupedBulk copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedBulkBillingModeTest : TestBase @@ -58881,6 +67535,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 @@ -59206,6 +67875,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 @@ -59288,6 +67979,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 @@ -59348,6 +68054,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] @@ -59394,6 +68195,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -59463,6 +68265,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -59511,6 +68319,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { @@ -59588,6 +68397,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); @@ -59631,6 +68446,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] @@ -59677,6 +68493,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -59746,6 +68563,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); @@ -59801,6 +68624,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -59870,6 +68694,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); @@ -59925,6 +68755,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { @@ -60002,6 +68833,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); @@ -60048,6 +68885,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -60094,6 +68932,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -60163,6 +69002,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -60212,6 +69057,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -60280,6 +69126,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] @@ -60326,6 +69174,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -60439,6 +69288,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -60505,10 +69355,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] @@ -60555,6 +69408,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -60621,10 +69475,138 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + CumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationBillingModeTest : TestBase @@ -60837,6 +69819,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 @@ -61124,6 +70121,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 @@ -61182,24 +70195,119 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class PriceMinimumTest : TestBase +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] public void FieldRoundtrip_Works() { - var model = new PriceMinimum + var model = 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"], }, ], @@ -61228,6 +70336,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -61281,16 +70390,22 @@ public void FieldRoundtrip_Works() 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() { DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -61300,20 +70415,20 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - PriceMinimumBillingMode.InAdvance; - ApiEnum expectedCadence = PriceMinimumCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + MinimumCompositeBillingMode.InAdvance; + ApiEnum expectedCadence = MinimumCompositeCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = MinimumCompositeCompositePriceFilterField.PriceID, + Operator = MinimumCompositeCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - PriceMinimumConversionRateConfig expectedConversionRateConfig = + MinimumCompositeConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -61338,6 +70453,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -61395,21 +70511,28 @@ public void FieldRoundtrip_Works() MinimumAmount = "minimum_amount", }; string expectedMinimumAmount = "minimum_amount"; - MinimumConfig expectedMinimumConfig = new() + MinimumCompositeMinimumCompositeConfig expectedMinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true, }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum_composite"); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = PriceMinimumPriceType.UsagePrice; + 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, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -61443,1531 +70566,18 @@ public void FieldRoundtrip_Works() } Assert.Equal(expectedMinimum, model.Minimum); Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); + Assert.Equal(expectedMinimumCompositeConfig, model.MinimumCompositeConfig); 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); + Assert.Equal(expectedLicenseType, model.LicenseType); } [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, - ReplacesPriceID = "replaces_price_id", - }; - - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_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", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_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 = null, - }; - - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_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 = null, - }; - - model.Validate(); - } -} - -public class PriceMinimumBillingModeTest : TestBase -{ - [Theory] - [InlineData(PriceMinimumBillingMode.InAdvance)] - [InlineData(PriceMinimumBillingMode.InArrear)] - public void Validation_Works(PriceMinimumBillingMode 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(PriceMinimumBillingMode.InAdvance)] - [InlineData(PriceMinimumBillingMode.InArrear)] - public void SerializationRoundtrip_Works(PriceMinimumBillingMode 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 PriceMinimumCadenceTest : 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) - { - // 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.OneTime)] - [InlineData(PriceMinimumCadence.Monthly)] - [InlineData(PriceMinimumCadence.Quarterly)] - [InlineData(PriceMinimumCadence.SemiAnnual)] - [InlineData(PriceMinimumCadence.Annual)] - [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 PriceMinimumCompositePriceFilterTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new PriceMinimumCompositePriceFilter - { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }; - - ApiEnum expectedField = - PriceMinimumCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - PriceMinimumCompositePriceFilterOperator.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 PriceMinimumCompositePriceFilter - { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.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 PriceMinimumCompositePriceFilter - { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - ApiEnum expectedField = - PriceMinimumCompositePriceFilterField.PriceID; - ApiEnum expectedOperator = - PriceMinimumCompositePriceFilterOperator.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 PriceMinimumCompositePriceFilter - { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }; - - model.Validate(); - } -} - -public class PriceMinimumCompositePriceFilterFieldTest : TestBase -{ - [Theory] - [InlineData(PriceMinimumCompositePriceFilterField.PriceID)] - [InlineData(PriceMinimumCompositePriceFilterField.ItemID)] - [InlineData(PriceMinimumCompositePriceFilterField.PriceType)] - [InlineData(PriceMinimumCompositePriceFilterField.Currency)] - [InlineData(PriceMinimumCompositePriceFilterField.PricingUnitID)] - public void Validation_Works(PriceMinimumCompositePriceFilterField 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(PriceMinimumCompositePriceFilterField.PriceID)] - [InlineData(PriceMinimumCompositePriceFilterField.ItemID)] - [InlineData(PriceMinimumCompositePriceFilterField.PriceType)] - [InlineData(PriceMinimumCompositePriceFilterField.Currency)] - [InlineData(PriceMinimumCompositePriceFilterField.PricingUnitID)] - public void SerializationRoundtrip_Works(PriceMinimumCompositePriceFilterField 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 PriceMinimumCompositePriceFilterOperatorTest : TestBase -{ - [Theory] - [InlineData(PriceMinimumCompositePriceFilterOperator.Includes)] - [InlineData(PriceMinimumCompositePriceFilterOperator.Excludes)] - public void Validation_Works(PriceMinimumCompositePriceFilterOperator 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(PriceMinimumCompositePriceFilterOperator.Includes)] - [InlineData(PriceMinimumCompositePriceFilterOperator.Excludes)] - public void SerializationRoundtrip_Works(PriceMinimumCompositePriceFilterOperator 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 PriceMinimumConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - PriceMinimumConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - PriceMinimumConversionRateConfig 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() - { - 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() - { - PriceMinimumConversionRateConfig 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 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 PriceMinimumPriceTypeTest : TestBase -{ - [Theory] - [InlineData(PriceMinimumPriceType.UsagePrice)] - [InlineData(PriceMinimumPriceType.FixedPrice)] - [InlineData(PriceMinimumPriceType.CompositePrice)] - public void Validation_Works(PriceMinimumPriceType 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(PriceMinimumPriceType.UsagePrice)] - [InlineData(PriceMinimumPriceType.FixedPrice)] - [InlineData(PriceMinimumPriceType.CompositePrice)] - public void SerializationRoundtrip_Works(PriceMinimumPriceType 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 MinimumCompositeTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() { var model = new MinimumComposite { @@ -63010,6 +70620,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -63073,274 +70684,11 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, - }; - - 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, 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(expectedMinimumCompositeConfig, model.MinimumCompositeConfig); - 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 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", }, }; @@ -63397,6 +70745,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -63460,6 +70809,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); @@ -63514,6 +70869,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -63587,6 +70943,12 @@ public void FieldRoundtripThroughSerialization_Works() 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); @@ -63630,6 +70992,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -63676,6 +71039,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -63739,6 +71103,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -63788,6 +71158,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -63850,6 +71221,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] @@ -63896,6 +71269,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -64003,6 +71377,121 @@ 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", + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + Name = "name", + PlanPhaseOrder = 0, + PriceType = MinimumCompositePriceType.UsagePrice, + 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] + public void OptionalNullablePropertiesSetToNullValidation_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() @@ -64063,14 +71552,14 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void CopyConstructor_Works() { var model = new MinimumComposite { @@ -64113,6 +71602,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -64171,11 +71661,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() PlanPhaseOrder = 0, PriceType = MinimumCompositePriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - - DimensionalPriceConfiguration = null, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; - model.Validate(); + MinimumComposite copied = new(model); + + Assert.Equal(model, copied); } } @@ -64393,6 +71894,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 @@ -64702,6 +72218,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 @@ -64764,6 +72294,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] @@ -64810,6 +72435,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -64873,6 +72499,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -64919,6 +72551,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -64987,6 +72620,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); @@ -65027,6 +72666,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] @@ -65073,6 +72713,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65136,6 +72777,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); @@ -65188,6 +72835,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65251,6 +72899,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); @@ -65304,6 +72958,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -65372,6 +73027,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); @@ -65415,6 +73076,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -65461,6 +73123,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65524,6 +73187,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -65573,6 +73242,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65635,6 +73305,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] @@ -65681,6 +73353,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65788,6 +73461,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65848,10 +73522,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] @@ -65898,6 +73575,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65958,10 +73636,132 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; 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"], + }, + ], + 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", + PercentConfig = new(0), + PlanPhaseOrder = 0, + PriceType = PercentPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + Percent copied = new(model); + + Assert.Equal(model, copied); + } } public class PercentBillingModeTest : TestBase @@ -66178,6 +73978,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 @@ -66423,6 +74238,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 @@ -66485,6 +74310,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] @@ -66531,6 +74451,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -66599,6 +74520,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -66646,6 +74573,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -66719,6 +74647,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); @@ -66759,6 +74693,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] @@ -66805,6 +74740,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -66873,6 +74809,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); @@ -66928,6 +74870,306 @@ 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", + }, + 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 = 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 = + EventOutputBillingMode.InAdvance; + ApiEnum expectedCadence = EventOutputCadence.OneTime; + List expectedCompositePriceFilters = + [ + new() + { + Field = EventOutputCompositePriceFilterField.PriceID, + Operator = EventOutputCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ]; + double expectedConversionRate = 0; + EventOutputConversionRateConfig 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", + }; + EventOutputConfig expectedEventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + 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"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + string expectedName = "name"; + long expectedPlanPhaseOrder = 0; + ApiEnum expectedPriceType = EventOutputPriceType.UsagePrice; + string expectedReplacesPriceID = "replaces_price_id"; + DimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + 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); + 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(expectedEventOutputConfig, deserialized.EventOutputConfig); + 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.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 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"], + }, + ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -66996,180 +75238,19 @@ 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 = - EventOutputBillingMode.InAdvance; - ApiEnum expectedCadence = EventOutputCadence.OneTime; - List expectedCompositePriceFilters = - [ - new() - { - Field = EventOutputCompositePriceFilterField.PriceID, - Operator = EventOutputCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ]; - double expectedConversionRate = 0; - EventOutputConversionRateConfig 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, + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, - 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", - }; - EventOutputConfig expectedEventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; - 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"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); - string expectedName = "name"; - long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = EventOutputPriceType.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(expectedEventOutputConfig, deserialized.EventOutputConfig); - 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.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 - ); + model.Validate(); } [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new EventOutput { @@ -67212,6 +75293,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67275,18 +75357,16 @@ public void Validation_Works() PlanPhaseOrder = 0, PriceType = EventOutputPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, }; - model.Validate(); + 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 OptionalNullablePropertiesUnsetAreNotSet_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { var model = new EventOutput { @@ -67329,6 +75409,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67394,12 +75475,11 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() ReplacesPriceID = "replaces_price_id", }; - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = new EventOutput { @@ -67442,6 +75522,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67505,13 +75586,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() PlanPhaseOrder = 0, PriceType = EventOutputPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", + + DimensionalPriceConfiguration = null, + LicenseType = null, }; - model.Validate(); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = new EventOutput { @@ -67554,6 +75641,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67619,14 +75707,14 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void CopyConstructor_Works() { var model = new EventOutput { @@ -67669,6 +75757,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67732,11 +75821,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() PlanPhaseOrder = 0, PriceType = EventOutputPriceType.UsagePrice, ReplacesPriceID = "replaces_price_id", - - DimensionalPriceConfiguration = null, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; - model.Validate(); + EventOutput copied = new(model); + + Assert.Equal(model, copied); } } @@ -67954,6 +76054,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 @@ -68275,6 +76390,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 @@ -68336,3 +76466,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/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/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..33ba1c5f8 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" } }, }, }; @@ -145,6 +148,57 @@ 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }, + }; + + PriceCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class BodyTest : TestBase @@ -187,6 +241,7 @@ public void NewFloatingUnitPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -242,6 +297,7 @@ public void NewFloatingTieredPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -285,6 +341,7 @@ public void NewFloatingBulkPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -335,6 +392,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -378,6 +436,7 @@ public void NewFloatingPackagePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -426,6 +485,7 @@ public void NewFloatingMatrixPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -477,6 +537,7 @@ public void NewFloatingThresholdTotalAmountPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -528,6 +589,7 @@ public void NewFloatingTieredPackagePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -590,6 +652,7 @@ public void NewFloatingTieredWithMinimumPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -641,6 +704,7 @@ public void NewFloatingGroupedTieredPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -703,6 +767,7 @@ public void NewFloatingTieredPackageWithMinimumPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -752,6 +817,7 @@ public void NewFloatingPackageWithAllocationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -795,6 +861,7 @@ public void NewFloatingUnitWithPercentPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -844,6 +911,7 @@ public void NewFloatingMatrixWithAllocationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -889,6 +957,7 @@ public void NewFloatingTieredWithProrationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -932,6 +1001,7 @@ public void NewFloatingUnitWithProrationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -980,6 +1050,7 @@ public void NewFloatingGroupedAllocationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1028,6 +1099,7 @@ public void NewFloatingBulkWithProrationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1077,6 +1149,7 @@ public void NewFloatingGroupedWithProratedMinimumPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1135,6 +1208,7 @@ public void NewFloatingGroupedWithMeteredMinimumPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1183,6 +1257,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1239,6 +1314,7 @@ public void NewFloatingMatrixWithDisplayNamePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1291,6 +1367,7 @@ public void NewFloatingGroupedTieredPackagePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1344,6 +1421,7 @@ public void NewFloatingMaxGroupTieredPackagePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1373,6 +1451,7 @@ public void NewFloatingScalableMatrixWithUnitPricingPriceValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -1403,6 +1482,7 @@ public void NewFloatingScalableMatrixWithUnitPricingPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1465,6 +1545,7 @@ public void NewFloatingScalableMatrixWithTieredPricingPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1521,6 +1602,7 @@ public void NewFloatingCumulativeGroupedBulkPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1569,48 +1651,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - 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, - }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1654,6 +1695,7 @@ public void NewFloatingMinimumCompositePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1696,6 +1738,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1743,6 +1786,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1786,6 +1830,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); @@ -1844,6 +1889,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); @@ -1890,6 +1936,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); @@ -1943,6 +1990,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); @@ -1989,6 +2037,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); @@ -2040,6 +2089,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); @@ -2094,6 +2144,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); @@ -2148,6 +2199,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); @@ -2213,6 +2265,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); @@ -2267,6 +2320,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); @@ -2332,6 +2386,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); @@ -2384,6 +2439,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); @@ -2430,6 +2486,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); @@ -2482,6 +2539,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); @@ -2530,6 +2588,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); @@ -2576,6 +2635,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); @@ -2627,6 +2687,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); @@ -2678,6 +2739,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); @@ -2730,6 +2792,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); @@ -2791,6 +2854,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); @@ -2842,6 +2906,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); @@ -2901,6 +2966,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); @@ -2956,6 +3022,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); @@ -3012,6 +3079,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); @@ -3044,6 +3112,7 @@ public void NewFloatingScalableMatrixWithUnitPricingPriceSerializationRoundtripW }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -3074,6 +3143,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); @@ -3139,6 +3209,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); @@ -3198,6 +3269,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); @@ -3249,51 +3321,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() 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 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, - }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3340,6 +3368,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); @@ -3385,6 +3414,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); @@ -3435,6 +3465,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); @@ -3491,6 +3522,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -3536,6 +3568,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); @@ -3554,6 +3587,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) @@ -3609,6 +3643,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -3666,6 +3701,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -3718,6 +3754,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); @@ -3739,6 +3776,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) @@ -3794,6 +3832,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -3840,6 +3879,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")); } @@ -3896,6 +3937,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -3919,6 +3961,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")); } @@ -3952,11 +3996,66 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = 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 = 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + BulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithFiltersConfigTest : TestBase @@ -4069,6 +4168,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 @@ -4119,6 +4236,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 @@ -4213,6 +4340,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 @@ -4403,6 +4540,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4449,6 +4587,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); @@ -4470,6 +4609,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) @@ -4523,6 +4663,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4578,6 +4719,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4631,6 +4773,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); @@ -4655,6 +4798,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) @@ -4708,6 +4852,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4752,6 +4897,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")); } @@ -4804,6 +4951,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -4827,6 +4975,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")); } @@ -4858,11 +5008,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsCadenceTest : TestBase @@ -5015,7 +5218,23 @@ 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 { @@ -5145,6 +5364,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5191,6 +5411,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); @@ -5212,6 +5433,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) @@ -5265,6 +5487,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5320,6 +5543,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5373,6 +5597,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); @@ -5397,6 +5622,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) @@ -5450,6 +5676,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5494,6 +5721,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")); } @@ -5546,6 +5775,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5569,6 +5799,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")); } @@ -5600,11 +5832,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = 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", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + CumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationCadenceTest : TestBase @@ -5757,6 +6042,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 @@ -5842,18 +6143,18 @@ 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, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5881,19 +6182,16 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; - ApiEnum expectedCadence = MinimumCadence.Annual; + ApiEnum expectedCadence = PercentCadence.Annual; string expectedCurrency = "currency"; 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() @@ -5902,7 +6200,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = + PercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5922,14 +6220,15 @@ 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); 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(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -5940,6 +6239,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) @@ -5953,13 +6253,13 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5987,11 +6287,12 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "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); } @@ -5999,13 +6300,13 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6033,26 +6334,23 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; 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 expectedCurrency = "currency"; 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() @@ -6061,7 +6359,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = + PercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6081,14 +6379,15 @@ 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); 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(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -6102,6 +6401,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) @@ -6115,13 +6415,13 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6149,6 +6449,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6158,13 +6459,13 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -6187,6 +6488,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")); } @@ -6194,13 +6497,13 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), }; model.Validate(); @@ -6209,13 +6512,13 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -6227,6 +6530,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6250,6 +6554,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")); } @@ -6257,13 +6563,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Minimum + var model = new Percent { - Cadence = MinimumCadence.Annual, + Cadence = PercentCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -6275,33 +6581,80 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + Percent copied = new(model); + + Assert.Equal(model, copied); + } } -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 ); @@ -6311,19 +6664,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 ); @@ -6334,12 +6687,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 ); @@ -6348,27 +6701,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 ); @@ -6379,83 +6730,45 @@ 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" }; + var model = new PercentConfig { Percent = 0 }; 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() + public void CopyConstructor_Works() { - var model = new MinimumConfig - { - MinimumAmount = "minimum_amount", + var model = new PercentConfig { Percent = 0 }; - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + PercentConfig copied = new(model); - model.Validate(); + Assert.Equal(model, copied); } } -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"), @@ -6466,7 +6779,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -6486,13 +6799,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 ); @@ -6503,7 +6816,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, TieredConfig = new( @@ -6518,7 +6831,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6527,18 +6840,23 @@ 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, Currency = "currency", + 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() @@ -6566,15 +6884,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; - ApiEnum expectedCadence = PercentCadence.Annual; + ApiEnum expectedCadence = EventOutputCadence.Annual; string expectedCurrency = "currency"; + 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() @@ -6583,7 +6907,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PercentConversionRateConfig expectedConversionRateConfig = + EventOutputConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6603,14 +6927,15 @@ 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); Assert.Equal(expectedCurrency, model.Currency); + 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); @@ -6621,6 +6946,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) @@ -6634,646 +6960,9 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Percent + var model = new EventOutput { - 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" } }, - }; - - string json = 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, - 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" } }, - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - ApiEnum expectedCadence = PercentCadence.Annual; - string expectedCurrency = "currency"; - string expectedItemID = "item_id"; - 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"), - }; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_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.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( - 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 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" } }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Percent - { - Cadence = PercentCadence.Annual, - Currency = "currency", - 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.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 Percent - { - Cadence = PercentCadence.Annual, - Currency = "currency", - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Percent - { - Cadence = PercentCadence.Annual, - Currency = "currency", - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - - 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 Percent - { - Cadence = PercentCadence.Annual, - Currency = "currency", - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - - 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 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 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(); - } -} - -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, - 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" } }, - }; - - ApiEnum expectedCadence = EventOutputCadence.Annual; - string expectedCurrency = "currency"; - 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"), - }; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_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(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(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 EventOutput - { - Cadence = EventOutputCadence.Annual, + Cadence = EventOutputCadence.Annual, Currency = "currency", EventOutputConfig = new() { @@ -7310,6 +6999,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7364,6 +7054,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7413,6 +7104,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); @@ -7434,6 +7126,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) @@ -7486,6 +7179,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7529,6 +7223,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")); } @@ -7579,6 +7275,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7602,6 +7299,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")); } @@ -7632,11 +7331,63 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + EventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class EventOutputCadenceTest : TestBase @@ -7833,6 +7584,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 e37fc01b4..1c4ce9217 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, @@ -62,6 +66,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -80,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, @@ -116,6 +125,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -181,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, @@ -217,6 +231,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -244,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, @@ -280,6 +299,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -309,6 +329,75 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }, + PriceID = "price_id", + }, + ], + }; + + PriceEvaluateMultipleParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class PriceEvaluationTest : TestBase @@ -321,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, @@ -357,6 +450,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -368,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, @@ -403,6 +501,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string expectedPriceID = "price_id"; @@ -415,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); } @@ -427,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, @@ -463,6 +574,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -485,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, @@ -521,6 +637,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -539,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, @@ -574,6 +695,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string expectedPriceID = "price_id"; @@ -586,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); } @@ -598,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, @@ -634,6 +773,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -649,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, @@ -685,6 +829,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -701,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, @@ -737,6 +886,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -752,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, @@ -788,6 +942,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -807,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, @@ -843,6 +1002,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -866,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); @@ -892,6 +1054,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ExternalPriceID = null, Filter = null, + MetricParameterOverrides = null, Price = null, PriceID = null, }; @@ -900,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); @@ -915,12 +1080,72 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ExternalPriceID = null, Filter = null, + MetricParameterOverrides = null, Price = null, PriceID = null, }; 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }, + PriceID = "price_id", + }; + + PriceEvaluation copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceTest : TestBase @@ -963,6 +1188,7 @@ public void NewFloatingUnitValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1018,6 +1244,7 @@ public void NewFloatingTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1061,6 +1288,7 @@ public void NewFloatingBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1111,6 +1339,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1154,6 +1383,7 @@ public void NewFloatingPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1202,6 +1432,7 @@ public void NewFloatingMatrixValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1253,6 +1484,7 @@ public void NewFloatingThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1304,6 +1536,7 @@ public void NewFloatingTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1366,6 +1599,7 @@ public void NewFloatingTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1417,6 +1651,7 @@ public void NewFloatingGroupedTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1479,6 +1714,7 @@ public void NewFloatingTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1528,6 +1764,7 @@ public void NewFloatingPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1571,6 +1808,7 @@ public void NewFloatingUnitWithPercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1620,6 +1858,7 @@ public void NewFloatingMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1665,6 +1904,7 @@ public void NewFloatingTieredWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1708,6 +1948,7 @@ public void NewFloatingUnitWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1756,6 +1997,7 @@ public void NewFloatingGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1804,6 +2046,7 @@ public void NewFloatingBulkWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1853,6 +2096,7 @@ public void NewFloatingGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1911,6 +2155,7 @@ public void NewFloatingGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1959,6 +2204,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2015,6 +2261,7 @@ public void NewFloatingMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2067,6 +2314,7 @@ public void NewFloatingGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2120,6 +2368,7 @@ public void NewFloatingMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2149,6 +2398,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -2179,6 +2429,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2241,6 +2492,7 @@ public void NewFloatingScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2297,6 +2549,7 @@ public void NewFloatingCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2345,48 +2598,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - 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, - }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2430,6 +2642,7 @@ public void NewFloatingMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2472,6 +2685,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2519,6 +2733,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2562,6 +2777,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); @@ -2620,6 +2836,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); @@ -2666,6 +2883,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); @@ -2719,6 +2937,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); @@ -2765,6 +2984,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); @@ -2816,6 +3036,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); @@ -2870,6 +3091,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); @@ -2924,6 +3146,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); @@ -2989,6 +3212,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); @@ -3043,6 +3267,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); @@ -3108,6 +3333,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); @@ -3160,6 +3386,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); @@ -3206,6 +3433,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); @@ -3258,6 +3486,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); @@ -3306,6 +3535,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); @@ -3352,6 +3582,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); @@ -3403,6 +3634,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); @@ -3454,6 +3686,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); @@ -3506,6 +3739,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); @@ -3567,6 +3801,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); @@ -3618,6 +3853,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); @@ -3677,6 +3913,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); @@ -3732,6 +3969,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); @@ -3788,6 +4026,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); @@ -3820,6 +4059,7 @@ public void NewFloatingScalableMatrixWithUnitPricingSerializationRoundtripWorks( }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -3850,6 +4090,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); @@ -3915,6 +4156,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); @@ -3974,6 +4216,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); @@ -4025,51 +4268,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() 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 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, - }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4116,6 +4315,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); @@ -4161,6 +4361,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); @@ -4211,6 +4412,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); @@ -4267,6 +4469,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4313,6 +4516,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); @@ -4331,6 +4535,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) @@ -4386,6 +4591,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4443,6 +4649,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4496,6 +4703,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); @@ -4517,6 +4725,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) @@ -4572,6 +4781,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4618,6 +4828,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")); } @@ -4674,6 +4886,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -4697,6 +4910,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")); } @@ -4730,36 +4945,91 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } -} -public class PriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new PriceBulkWithFiltersBulkWithFiltersConfig + var model = new PriceBulkWithFilters { - 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" }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + 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); @@ -4853,6 +5123,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 @@ -4927,6 +5215,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 @@ -5051,6 +5353,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 @@ -5245,6 +5561,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5292,6 +5609,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); @@ -5313,6 +5631,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) @@ -5366,6 +5685,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5421,6 +5741,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5475,6 +5796,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); @@ -5499,6 +5821,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) @@ -5552,6 +5875,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5596,6 +5920,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")); } @@ -5648,6 +5974,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5671,6 +5998,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")); } @@ -5702,11 +6031,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PriceGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceGroupedWithMinMaxThresholdsCadenceTest : TestBase @@ -5859,6 +6241,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 @@ -5989,6 +6387,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6036,6 +6435,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); @@ -6057,6 +6457,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) @@ -6110,6 +6511,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6165,6 +6567,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6219,6 +6622,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); @@ -6243,6 +6647,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) @@ -6296,6 +6701,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6340,6 +6746,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")); } @@ -6392,6 +6800,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6415,6 +6824,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")); } @@ -6446,11 +6857,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = 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", + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PriceCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceCumulativeGroupedAllocationCadenceTest : TestBase @@ -6603,6 +7067,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 @@ -6688,18 +7168,18 @@ public void TieredSerializationRoundtripWorks() } } -public class PriceMinimumTest : TestBase +public class PricePercentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PriceMinimum + var model = new PricePercent { - Cadence = PriceMinimumCadence.Annual, + Cadence = PricePercentCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6727,19 +7207,16 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; - ApiEnum expectedCadence = PriceMinimumCadence.Annual; + ApiEnum expectedCadence = PricePercentCadence.Annual; string expectedCurrency = "currency"; string expectedItemID = "item_id"; - PriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + 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() @@ -6748,7 +7225,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceMinimumConversionRateConfig expectedConversionRateConfig = + PricePercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6768,14 +7245,15 @@ 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); 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(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -6786,6 +7264,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) @@ -6799,13 +7278,13 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new PriceMinimum + var model = new PricePercent { - Cadence = PriceMinimumCadence.Annual, + Cadence = PricePercentCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6833,11 +7312,12 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6848,13 +7328,13 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PriceMinimum + var model = new PricePercent { - Cadence = PriceMinimumCadence.Annual, + Cadence = PricePercentCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6882,26 +7362,23 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = PriceMinimumCadence.Annual; + ApiEnum expectedCadence = PricePercentCadence.Annual; string expectedCurrency = "currency"; string expectedItemID = "item_id"; - PriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + 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() @@ -6910,7 +7387,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceMinimumConversionRateConfig expectedConversionRateConfig = + PricePercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6930,14 +7407,15 @@ 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); 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(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -6951,6 +7429,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) @@ -6964,703 +7443,7 @@ public void FieldRoundtripThroughSerialization_Works() [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] - public void FieldRoundtrip_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" } }, - }; - - ApiEnum expectedCadence = PricePercentCadence.Annual; - string expectedCurrency = "currency"; - 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"), - }; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_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.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(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 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" } }, - }; - - string json = 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, - 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" } }, - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - ApiEnum expectedCadence = PricePercentCadence.Annual; - string expectedCurrency = "currency"; - 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"), - }; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_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.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( - 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 PricePercent + var model = new PricePercent { Cadence = PricePercentCadence.Annual, Currency = "currency", @@ -7694,6 +7477,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7732,6 +7516,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")); } @@ -7772,6 +7558,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7795,6 +7582,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")); } @@ -7820,11 +7609,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PricePercent copied = new(model); + + Assert.Equal(model, copied); + } } public class PricePercentCadenceTest : TestBase @@ -7943,6 +7779,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 @@ -8066,6 +7912,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8108,6 +7955,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); @@ -8126,6 +7974,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) @@ -8178,6 +8027,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8232,6 +8082,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8281,6 +8132,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); @@ -8302,6 +8154,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) @@ -8354,6 +8207,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8397,6 +8251,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")); } @@ -8447,6 +8303,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8470,6 +8327,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")); } @@ -8500,11 +8359,63 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PriceEventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceEventOutputCadenceTest : TestBase @@ -8701,6 +8612,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/PriceEvaluateParamsTest.cs b/src/Orb.Tests/Models/Prices/PriceEvaluateParamsTest.cs index 43543de01..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] @@ -138,4 +173,27 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + }; + + 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..1a6420dca 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, @@ -76,6 +80,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -108,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, @@ -143,6 +152,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -233,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, @@ -269,6 +283,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -310,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, @@ -346,6 +365,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -375,6 +395,89 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }, + PriceID = "price_id", + }, + ], + }; + + PriceEvaluatePreviewEventsParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class EventTest : TestBase @@ -571,6 +674,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 @@ -583,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, @@ -618,6 +745,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -629,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() { @@ -665,6 +797,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string expectedPriceID = "price_id"; @@ -677,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); } @@ -689,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, @@ -724,6 +869,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -747,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, @@ -782,6 +932,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -801,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() { @@ -837,6 +992,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string expectedPriceID = "price_id"; @@ -849,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); } @@ -861,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, @@ -896,6 +1069,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -911,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, @@ -946,6 +1124,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -962,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, @@ -997,6 +1180,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -1012,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, @@ -1047,6 +1235,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -1066,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, @@ -1101,6 +1294,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "price_id", @@ -1124,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); @@ -1150,6 +1346,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ExternalPriceID = null, Filter = null, + MetricParameterOverrides = null, Price = null, PriceID = null, }; @@ -1158,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); @@ -1173,12 +1372,71 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ExternalPriceID = null, Filter = null, + MetricParameterOverrides = null, Price = null, PriceID = null, }; 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }, + PriceID = "price_id", + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluation copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceTest : TestBase @@ -1221,6 +1479,7 @@ public void NewFloatingUnitValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1276,6 +1535,7 @@ public void NewFloatingTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1319,6 +1579,7 @@ public void NewFloatingBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1371,6 +1632,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1414,6 +1676,7 @@ public void NewFloatingPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1462,6 +1725,7 @@ public void NewFloatingMatrixValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1514,6 +1778,7 @@ public void NewFloatingThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1566,6 +1831,7 @@ public void NewFloatingTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1629,6 +1895,7 @@ public void NewFloatingTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1681,6 +1948,7 @@ public void NewFloatingGroupedTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1744,6 +2012,7 @@ public void NewFloatingTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1793,6 +2062,7 @@ public void NewFloatingPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1837,6 +2107,7 @@ public void NewFloatingUnitWithPercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1890,6 +2161,7 @@ public void NewFloatingMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1936,6 +2208,7 @@ public void NewFloatingTieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1980,6 +2253,7 @@ public void NewFloatingUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2029,6 +2303,7 @@ public void NewFloatingGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2078,6 +2353,7 @@ public void NewFloatingBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2128,6 +2404,7 @@ public void NewFloatingGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2191,6 +2468,7 @@ public void NewFloatingGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2241,6 +2519,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2297,6 +2576,7 @@ public void NewFloatingMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2350,6 +2630,7 @@ public void NewFloatingGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2403,6 +2684,7 @@ public void NewFloatingMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2433,6 +2715,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -2463,6 +2746,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2526,6 +2810,7 @@ public void NewFloatingScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2582,6 +2867,7 @@ public void NewFloatingCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2632,49 +2918,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - 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, - }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2723,6 +2967,7 @@ public void NewFloatingMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2766,6 +3011,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2815,6 +3061,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2858,6 +3105,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); @@ -2920,6 +3168,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); @@ -2970,6 +3219,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); @@ -3029,6 +3279,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); @@ -3079,6 +3330,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); @@ -3134,6 +3386,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); @@ -3193,6 +3446,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); @@ -3252,6 +3506,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); @@ -3322,6 +3577,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); @@ -3381,6 +3637,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); @@ -3451,6 +3708,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); @@ -3507,6 +3765,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); @@ -3558,6 +3817,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); @@ -3618,6 +3878,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); @@ -3671,6 +3932,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); @@ -3722,6 +3984,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); @@ -3778,6 +4041,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); @@ -3834,6 +4098,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); @@ -3891,6 +4156,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); @@ -3961,6 +4227,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); @@ -4018,6 +4285,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); @@ -4081,6 +4349,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); @@ -4141,6 +4410,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); @@ -4201,6 +4471,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); @@ -4238,6 +4509,7 @@ public void NewFloatingScalableMatrixWithUnitPricingSerializationRoundtripWorks( }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -4268,6 +4540,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); @@ -4338,6 +4611,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); @@ -4401,6 +4675,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); @@ -4458,6 +4733,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); @@ -4471,15 +4747,20 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void NewFloatingMinimumCompositeSerializationRoundtripWorks() { PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum() + new NewFloatingMinimumCompositePrice() { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + Cadence = NewFloatingMinimumCompositePriceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }, + ModelType = NewFloatingMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4508,6 +4789,7 @@ public void MinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4521,67 +4803,12 @@ public void MinimumSerializationRoundtripWorks() } [Fact] - public void NewFloatingMinimumCompositeSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = - new NewFloatingMinimumCompositePrice() + new PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent() { - 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" } }, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void PercentSerializationRoundtripWorks() - { - PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent() - { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadence.Annual, + Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadence.Annual, Currency = "currency", ItemID = "item_id", Name = "Annual fee", @@ -4613,6 +4840,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); @@ -4669,6 +4897,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); @@ -4730,6 +4959,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4780,6 +5010,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); @@ -4798,6 +5029,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) @@ -4854,6 +5086,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4913,6 +5146,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4971,6 +5205,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); @@ -4992,6 +5227,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) @@ -5048,6 +5284,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5095,6 +5332,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")); } @@ -5153,6 +5392,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5176,6 +5416,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")); } @@ -5210,11 +5452,67 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigTest @@ -5340,6 +5638,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 @@ -5419,6 +5737,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 @@ -5552,6 +5886,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 @@ -5779,6 +6129,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5829,6 +6180,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); @@ -5850,6 +6202,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) @@ -5905,6 +6258,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5963,6 +6317,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6021,6 +6376,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); @@ -6045,6 +6401,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) @@ -6100,6 +6457,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6146,6 +6504,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")); } @@ -6202,6 +6562,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6225,6 +6586,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")); } @@ -6258,11 +6621,67 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds copied = + new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadenceTest @@ -6467,6 +6886,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 @@ -6601,6 +7038,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6651,6 +7089,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); @@ -6672,6 +7111,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) @@ -6727,6 +7167,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6785,6 +7226,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6843,6 +7285,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); @@ -6867,6 +7310,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) @@ -6922,6 +7366,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6968,6 +7413,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")); } @@ -7024,6 +7471,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7047,6 +7495,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")); } @@ -7080,61 +7530,72 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } -} - -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadenceTest - : TestBase -{ - [Theory] - [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual - )] - [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.SemiAnnual - )] - [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Monthly - )] - [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Quarterly - )] - [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.OneTime - )] - [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Custom - )] - public void Validation_Works( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence - > value = rawValue; - value.Validate(); - } [Fact] - public void InvalidEnumValidationThrows_Works() + public void CopyConstructor_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadenceTest + : TestBase +{ [Theory] [InlineData( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual @@ -7154,7 +7615,7 @@ public void InvalidEnumValidationThrows_Works() [InlineData( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Custom )] - public void SerializationRoundtrip_Works( + public void Validation_Works( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence rawValue ) { @@ -7163,20 +7624,11 @@ PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationC string, PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence > value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence - > - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< ApiEnum< @@ -7184,692 +7636,46 @@ public void InvalidEnumSerializationRoundtrip_Works() PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence - > - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} - -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest - : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig - { - 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig - { - 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig - { - 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; - - model.Validate(); - } -} - -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfigTest - : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } - - [Fact] - public void UnitSerializationRoundtripWorks() - { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig 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() - { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig 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 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)] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.SemiAnnual + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Monthly + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Quarterly + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.OneTime + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Custom + )] public void SerializationRoundtrip_Works( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence rawValue + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -7879,47 +7685,64 @@ PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence rawValue public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence + > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfigTest : TestBase +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 ); @@ -7930,99 +7753,75 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + 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 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", - }; + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_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() + public void CopyConstructor_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfigTest +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8034,7 +7833,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8055,7 +7854,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8063,7 +7862,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8074,7 +7873,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8091,7 +7890,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8139,6 +7938,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8181,6 +7981,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); @@ -8199,6 +8000,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) @@ -8246,6 +8048,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8296,6 +8099,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8346,6 +8150,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); @@ -8367,6 +8172,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) @@ -8414,6 +8220,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8452,6 +8259,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")); } @@ -8492,6 +8301,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8515,6 +8325,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")); } @@ -8540,11 +8352,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadenceTest : TestBase @@ -8679,6 +8538,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 @@ -8809,6 +8683,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8856,6 +8731,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); @@ -8874,6 +8750,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) @@ -8926,6 +8803,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8981,6 +8859,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9036,6 +8915,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); @@ -9057,6 +8937,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) @@ -9109,6 +8990,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9152,6 +9034,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")); } @@ -9202,6 +9086,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -9225,6 +9110,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")); } @@ -9255,11 +9142,63 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutputCadenceTest : TestBase @@ -9479,6 +9418,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/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/PriceListPageResponseTest.cs b/src/Orb.Tests/Models/Prices/PriceListPageResponseTest.cs index 2975d082f..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" }, @@ -789,4 +831,141 @@ 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + ], + PaginationMetadata = new() { HasMore = true, NextCursor = "next_cursor" }, + }; + + PriceListPageResponse copied = new(model); + + Assert.Equal(model, 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/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..98a19e334 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,9 +630,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -896,6 +914,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -977,6 +996,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 +1357,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1413,6 +1439,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 +1941,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1976,6 +2009,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 +2093,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2121,9 +2161,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ]; Models::CouponRedemption expectedRedeemedCoupon = new() @@ -2390,6 +2440,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2459,6 +2510,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 +2863,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2875,6 +2933,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 +3497,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3500,6 +3565,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 +3651,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3647,9 +3719,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -3921,6 +4003,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4002,6 +4085,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 +4446,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4438,6 +4528,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 +5040,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5011,6 +5108,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 +5194,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5158,9 +5262,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -5432,6 +5546,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5513,6 +5628,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 +5989,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5949,6 +6071,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 +6580,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6519,6 +6648,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 +6732,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6664,9 +6800,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ]; Models::CouponRedemption expectedRedeemedCoupon = new() @@ -6933,6 +7079,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7002,6 +7149,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 +7502,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7418,6 +7572,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 +8145,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8052,6 +8213,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 +8299,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8199,9 +8367,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -8473,6 +8651,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8554,6 +8733,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 +9094,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8990,6 +9176,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 +9682,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9557,6 +9750,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 +9836,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9704,9 +9904,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -10120,6 +10330,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10187,6 +10398,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 +10484,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10334,9 +10552,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -10749,6 +10977,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10816,6 +11045,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 +11131,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10963,9 +11199,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -11381,6 +11627,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11448,6 +11695,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 +11781,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11595,9 +11849,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -11615,6 +11879,1545 @@ 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + ], + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + 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") }, + }, + }, + ], + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + 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/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/SubscriptionChangeApplyResponseTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyResponseTest.cs index 182a97293..7dafea919 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,9 +646,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -927,6 +945,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1010,6 +1029,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 +1405,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1463,6 +1489,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 +2001,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2036,6 +2069,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 +2155,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2183,9 +2223,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -2457,6 +2507,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2538,6 +2589,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 +2950,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2974,6 +3032,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 +3566,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3570,6 +3635,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 +3723,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3720,9 +3792,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -4009,6 +4091,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4092,6 +4175,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 +4551,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4545,6 +4635,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 +5166,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5138,6 +5235,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 +5323,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5288,9 +5392,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -5577,6 +5691,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5660,6 +5775,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 +6151,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6113,6 +6235,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 +6754,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6693,6 +6822,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 +6908,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6840,9 +6976,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -7114,6 +7260,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7195,6 +7342,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 +7703,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7631,6 +7785,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 +8319,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8227,6 +8388,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 +8476,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8377,9 +8545,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -8666,6 +8844,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8749,6 +8928,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 +9304,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9202,6 +9388,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 +9913,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9789,6 +9982,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 +10070,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9939,9 +10139,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -10228,6 +10438,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10311,6 +10522,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 +10898,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10764,6 +10982,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 +11512,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11356,6 +11581,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 +11669,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11506,9 +11738,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -11795,6 +12037,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11878,6 +12121,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 +12497,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12331,6 +12581,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 +13100,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12912,6 +13169,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 +13257,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13062,9 +13326,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -13351,6 +13625,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13434,6 +13709,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 +14085,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13887,6 +14169,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 +14706,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14486,6 +14775,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 +14863,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14636,9 +14932,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -14925,6 +15231,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15008,6 +15315,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 +15691,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15461,6 +15775,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"), @@ -15572,6 +15892,1602 @@ 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + ], + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + 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") }, + }, + }, + ], + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + 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/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/SubscriptionChangeCancelResponseTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelResponseTest.cs index 90bc16c7c..36285cc65 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,9 +646,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -927,6 +945,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1010,6 +1029,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 +1405,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1463,6 +1489,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 +2001,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2036,6 +2069,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 +2155,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2183,9 +2223,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -2457,6 +2507,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2538,6 +2589,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 +2950,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2974,6 +3032,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 +3566,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3570,6 +3635,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 +3723,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3720,9 +3792,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -4009,6 +4091,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4092,6 +4175,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 +4551,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4545,6 +4635,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 +5166,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5138,6 +5235,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 +5323,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5288,9 +5392,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -5577,6 +5691,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5660,6 +5775,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 +6151,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6113,6 +6235,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 +6754,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6693,6 +6822,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 +6908,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6840,9 +6976,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -7114,6 +7260,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7195,6 +7342,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 +7703,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7631,6 +7785,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 +8319,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8227,6 +8388,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 +8476,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8377,9 +8545,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -8666,6 +8844,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8749,6 +8928,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 +9304,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9202,6 +9388,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 +9913,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9789,6 +9982,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 +10070,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9939,9 +10139,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -10228,6 +10438,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10311,6 +10522,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 +10898,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10764,6 +10982,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 +11512,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11356,6 +11581,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 +11669,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11506,9 +11738,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -11795,6 +12037,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11878,6 +12121,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 +12497,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12331,6 +12581,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 +13100,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12912,6 +13169,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 +13257,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13062,9 +13326,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -13351,6 +13625,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13434,6 +13709,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 +14085,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13887,6 +14169,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 +14706,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14486,6 +14775,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 +14863,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14636,9 +14932,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -14925,6 +15231,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15008,6 +15315,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 +15691,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15461,6 +15775,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"), @@ -15572,6 +15892,1602 @@ 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + ], + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + 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") }, + }, + }, + ], + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + 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/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/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/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/SubscriptionChanges/SubscriptionChangeRetrieveResponseTest.cs b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponseTest.cs index 85d31234a..0ad1501cd 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,9 +646,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -927,6 +945,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1010,6 +1029,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 +1405,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1463,6 +1489,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 +2001,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2036,6 +2069,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 +2155,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2183,9 +2223,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -2457,6 +2507,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2538,6 +2589,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 +2950,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2974,6 +3032,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 +3566,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3570,6 +3635,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 +3723,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3720,9 +3792,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -4009,6 +4091,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4092,6 +4175,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 +4551,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4545,6 +4635,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 +5166,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5138,6 +5235,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 +5323,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5288,9 +5392,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -5577,6 +5691,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5660,6 +5775,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 +6151,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6113,6 +6235,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 +6754,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6693,6 +6822,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 +6908,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6840,9 +6976,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -7114,6 +7260,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7195,6 +7342,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 +7703,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7631,6 +7785,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 +8319,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8227,6 +8388,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 +8476,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8377,9 +8545,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -8666,6 +8844,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8749,6 +8928,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 +9304,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9202,6 +9388,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 +9913,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9789,6 +9982,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 +10070,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9939,9 +10139,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -10228,6 +10438,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10311,6 +10522,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 +10898,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10764,6 +10982,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 +11512,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11356,6 +11581,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 +11669,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11506,9 +11738,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -11795,6 +12037,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11878,6 +12121,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 +12497,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12331,6 +12581,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 +13100,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12912,6 +13169,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 +13257,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13062,9 +13326,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -13351,6 +13625,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13434,6 +13709,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 +14085,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13887,6 +14169,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 +14706,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14486,6 +14775,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 +14863,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14636,9 +14932,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -14925,6 +15231,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15008,6 +15315,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 +15691,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15461,6 +15775,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"), @@ -15572,6 +15892,1602 @@ 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + ], + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + 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") }, + }, + }, + ], + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + 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"], + }, + ], + LicenseTypeID = "license_type_id", + }, + 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", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }, + 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..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,12 +477,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,12 +545,67 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionBulkWithProrationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithProrationConfigTest : TestBase @@ -634,6 +702,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 +835,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..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,12 +615,74 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionCumulativeGroupedBulkPriceCadenceTest : TestBase @@ -804,6 +879,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 +981,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..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,12 +545,67 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionGroupedAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionGroupedAllocationPriceCadenceTest : TestBase @@ -686,6 +754,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..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,12 +585,71 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionGroupedTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionGroupedTieredPackagePriceCadenceTest : TestBase @@ -758,6 +830,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 +923,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..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,12 +563,69 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionGroupedTieredPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionGroupedTieredPriceCadenceTest : TestBase @@ -724,6 +794,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 +884,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..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,12 +645,76 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionGroupedWithMeteredMinimumPriceCadenceTest : TestBase @@ -864,6 +941,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 +1037,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 +1123,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..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,12 +555,67 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionGroupedWithProratedMinimumPriceCadenceTest : TestBase @@ -702,6 +770,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..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,12 +525,66 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,12 +535,67 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,12 +615,74 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionMatrixWithDisplayNamePriceCadenceTest : TestBase @@ -804,6 +879,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 +983,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..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,12 +585,71 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionMaxGroupTieredPackagePriceCadenceTest : TestBase @@ -758,6 +830,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 +923,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..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,12 +503,62 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionMinimumCompositePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionMinimumCompositePriceCadenceTest : TestBase @@ -682,6 +745,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..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,12 +483,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,12 +545,67 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionPackageWithAllocationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionPackageWithAllocationPriceCadenceTest : TestBase @@ -748,6 +816,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..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,12 +693,81 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionScalableMatrixWithTieredPricingPriceCadenceTest : TestBase @@ -1140,6 +1222,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 +1384,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 +1473,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..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", }, @@ -64,6 +65,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -94,6 +96,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -126,6 +129,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 +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) @@ -183,6 +188,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -214,6 +220,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -252,6 +259,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -283,6 +291,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -321,6 +330,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -353,6 +363,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 +389,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) @@ -413,6 +425,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -444,6 +457,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -475,6 +489,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -502,6 +517,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); @@ -532,6 +549,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -564,6 +582,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -579,6 +598,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -605,6 +625,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); @@ -635,6 +657,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -650,12 +673,79 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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", + GroupingKey = "x", + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionScalableMatrixWithUnitPricingPriceCadenceTest : TestBase @@ -826,6 +916,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -841,6 +932,7 @@ public void FieldRoundtrip_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -851,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); } @@ -871,6 +964,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -901,6 +995,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -924,6 +1019,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -934,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); } @@ -954,6 +1051,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -979,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); @@ -1023,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); @@ -1050,12 +1153,39 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ], UnitPrice = "unit_price", + GroupingKey = null, Prorate = null, SecondDimension = null, }; 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", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + Subscriptions::ScalableMatrixWithUnitPricingConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithUnitPricingConfigMatrixScalingFactorTest : TestBase @@ -1192,6 +1322,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..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,12 +575,70 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionThresholdTotalAmountPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionThresholdTotalAmountPriceCadenceTest : TestBase @@ -868,6 +939,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 +1029,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..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,12 +563,69 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionTieredPackagePrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionTieredPackagePriceCadenceTest : TestBase @@ -778,6 +848,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 +938,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..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,12 +680,80 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionTieredPackageWithMinimumPriceCadenceTest : TestBase @@ -973,6 +1054,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 +1164,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..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,12 +595,73 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,12 +685,81 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionTieredWithMinimumPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionTieredWithMinimumPriceCadenceTest : TestBase @@ -1090,6 +1172,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 +1281,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..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,12 +475,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + 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..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,12 +491,61 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionUnitWithPercentPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionUnitWithPercentPriceCadenceTest : TestBase @@ -678,6 +740,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..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,12 +495,62 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::NewSubscriptionUnitWithProrationPrice copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSubscriptionUnitWithProrationPriceCadenceTest : TestBase @@ -666,6 +729,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/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..11dbc6028 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 = @@ -84,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() @@ -122,6 +127,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -216,6 +222,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -231,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() { @@ -268,6 +279,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -333,6 +345,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -348,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() @@ -385,6 +402,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -480,6 +498,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -495,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() { @@ -531,6 +554,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -693,6 +717,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -708,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() @@ -746,6 +775,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -839,6 +869,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -854,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() { @@ -891,6 +926,7 @@ public void OptionalNonNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -967,6 +1003,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -982,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() @@ -1020,6 +1061,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1113,6 +1155,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -1128,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() { @@ -1165,6 +1212,7 @@ public void OptionalNonNullableParamsSetToNullAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -1375,145 +1423,325 @@ public void Url_Works() Assert.Equal(new Uri("https://api.withorb.com/v1/subscriptions"), url); } -} -public class AddAdjustmentTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new Subscriptions::AddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - Subscriptions::Adjustment expectedAdjustment = new NewPercentageDiscount() + var parameters = new Subscriptions::SubscriptionCreateParams { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + AddAdjustments = [ new() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }, ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - long expectedPlanPhaseOrder = 0; - DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedEndDate, model.EndDate); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - Assert.Equal(expectedStartDate, model.StartDate); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::AddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() + AddPrices = + [ + new() + { + AllocationPrice = new() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Subscriptions::AddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() + Discounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalPriceID = "external_price_id", + MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + { "foo", JsonSerializer.SerializeToElement("bar") }, }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + 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, + }, + LicenseTypeID = "license_type_id", + 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"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + 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", + LicenseTypeID = "license_type_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", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::AddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; Subscriptions::Adjustment expectedAdjustment = new NewPercentageDiscount() { @@ -1539,14 +1767,14 @@ public void FieldRoundtripThroughSerialization_Works() long expectedPlanPhaseOrder = 0; DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedEndDate, deserialized.EndDate); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedStartDate, deserialized.StartDate); + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(expectedStartDate, model.StartDate); } [Fact] - public void Validation_Works() + public void SerializationRoundtrip_Works() { var model = new Subscriptions::AddAdjustment { @@ -1575,11 +1803,17 @@ public void Validation_Works() StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; - model.Validate(); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void FieldRoundtripThroughSerialization_Works() { var model = new Subscriptions::AddAdjustment { @@ -1603,18 +1837,50 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() 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"), }; - Assert.Null(model.EndDate); - Assert.False(model.RawData.ContainsKey("end_date")); - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.StartDate); - Assert.False(model.RawData.ContainsKey("start_date")); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Subscriptions::Adjustment expectedAdjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + long expectedPlanPhaseOrder = 0; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedStartDate, deserialized.StartDate); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void Validation_Works() { var model = new Subscriptions::AddAdjustment { @@ -1638,13 +1904,16 @@ public void OptionalNullablePropertiesUnsetValidation_Works() IsInvoiceLevel = true, PriceType = NewPercentageDiscountPriceType.Usage, }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new Subscriptions::AddAdjustment { @@ -1668,16 +1937,81 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() IsInvoiceLevel = true, PriceType = NewPercentageDiscountPriceType.Usage, }, - - EndDate = null, - PlanPhaseOrder = null, - StartDate = null, }; Assert.Null(model.EndDate); - Assert.True(model.RawData.ContainsKey("end_date")); + Assert.False(model.RawData.ContainsKey("end_date")); Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.StartDate); + Assert.False(model.RawData.ContainsKey("start_date")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Subscriptions::AddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::AddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + + EndDate = null, + PlanPhaseOrder = null, + StartDate = null, + }; + + Assert.Null(model.EndDate); + Assert.True(model.RawData.ContainsKey("end_date")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); Assert.Null(model.StartDate); Assert.True(model.RawData.ContainsKey("start_date")); } @@ -1715,6 +2049,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 @@ -2040,6 +2409,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -2055,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() @@ -2092,6 +2466,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2120,6 +2495,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; List expectedDiscounts = @@ -2135,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() @@ -2172,6 +2552,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2188,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); @@ -2221,6 +2610,7 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -2236,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() @@ -2273,6 +2667,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2315,6 +2710,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -2330,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() @@ -2367,6 +2767,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2402,6 +2803,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; List expectedDiscounts = @@ -2417,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() @@ -2454,6 +2860,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2470,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); @@ -2503,6 +2923,7 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -2518,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() @@ -2555,6 +2980,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -2580,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); @@ -2610,6 +3038,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() EndDate = null, ExternalPriceID = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, PlanPhaseOrder = null, Price = null, @@ -2627,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); @@ -2649,6 +3080,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() EndDate = null, ExternalPriceID = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, PlanPhaseOrder = null, Price = null, @@ -2658,6 +3090,102 @@ 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", + LicenseTypeID = "license_type_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", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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 @@ -2700,6 +3228,7 @@ public void NewSubscriptionUnitValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2756,6 +3285,7 @@ public void NewSubscriptionTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2800,6 +3330,7 @@ public void NewSubscriptionBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2851,6 +3382,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2895,6 +3427,7 @@ public void NewSubscriptionPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2944,6 +3477,7 @@ public void NewSubscriptionMatrixValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2997,6 +3531,7 @@ public void NewSubscriptionThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3049,6 +3584,7 @@ public void NewSubscriptionTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3113,6 +3649,7 @@ public void NewSubscriptionTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3165,6 +3702,7 @@ public void NewSubscriptionGroupedTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3229,6 +3767,7 @@ public void NewSubscriptionTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3279,6 +3818,7 @@ public void NewSubscriptionPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3323,6 +3863,7 @@ public void NewSubscriptionUnitWithPercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3374,6 +3915,7 @@ public void NewSubscriptionMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3419,6 +3961,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3464,6 +4007,7 @@ public void NewSubscriptionUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3514,6 +4058,7 @@ public void NewSubscriptionGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3564,6 +4109,7 @@ public void NewSubscriptionBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3616,6 +4162,7 @@ public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3681,6 +4228,7 @@ public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3730,6 +4278,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3787,6 +4336,7 @@ public void NewSubscriptionMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3841,6 +4391,7 @@ public void NewSubscriptionGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3895,6 +4446,7 @@ public void NewSubscriptionMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3926,6 +4478,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -3957,6 +4510,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4022,6 +4576,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4079,6 +4634,7 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4128,49 +4684,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - 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, - }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4216,6 +4730,7 @@ public void NewSubscriptionMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4259,6 +4774,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4307,6 +4823,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4351,6 +4868,7 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4413,6 +4931,7 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4463,6 +4982,7 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4520,6 +5040,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4570,6 +5091,7 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4625,6 +5147,7 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4684,6 +5207,7 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4742,6 +5266,7 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4812,6 +5337,7 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4870,6 +5396,7 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4940,6 +5467,7 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4996,6 +5524,7 @@ public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5046,6 +5575,7 @@ public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5103,6 +5633,7 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5154,6 +5685,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5205,6 +5737,7 @@ public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5261,6 +5794,7 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5317,6 +5851,7 @@ public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5375,6 +5910,7 @@ public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5446,6 +5982,7 @@ public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks( Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5501,6 +6038,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5564,6 +6102,7 @@ public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5624,6 +6163,7 @@ public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5684,6 +6224,7 @@ public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5721,6 +6262,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -5752,6 +6294,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5823,6 +6366,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtrip Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5886,6 +6430,7 @@ public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5941,6 +6486,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5954,60 +6500,11 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() { - Subscriptions::Price value = new Subscriptions::Minimum() + Subscriptions::Price value = new Subscriptions::NewSubscriptionMinimumCompositePrice() { - 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() - { - Subscriptions::Price value = new Subscriptions::NewSubscriptionMinimumCompositePrice() - { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, ItemID = "item_id", MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, ModelType = @@ -6041,6 +6538,7 @@ public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6090,6 +6588,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6144,6 +6643,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6204,6 +6704,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6250,6 +6751,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -6269,6 +6771,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) @@ -6325,6 +6828,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6383,6 +6887,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6436,6 +6941,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -6458,6 +6964,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) @@ -6514,6 +7021,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6562,6 +7070,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); @@ -6619,6 +7129,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6645,6 +7156,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); @@ -6680,12 +7193,68 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::BulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithFiltersConfigTest : TestBase @@ -6804,6 +7373,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 @@ -6860,6 +7447,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 @@ -6976,6 +7573,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 @@ -7162,6 +7773,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7203,6 +7815,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -7222,6 +7835,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) @@ -7272,6 +7886,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7324,6 +7939,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7372,6 +7988,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -7394,6 +8011,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) @@ -7444,6 +8062,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7486,6 +8105,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); @@ -7531,6 +8152,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7557,6 +8179,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); @@ -7586,12 +8210,62 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::TieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationCadenceTest : TestBase @@ -7732,6 +8406,19 @@ 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 @@ -7804,6 +8491,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 @@ -7934,6 +8635,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7982,6 +8684,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8004,6 +8707,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) @@ -8058,6 +8762,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8114,6 +8819,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8169,6 +8875,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8194,6 +8901,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) @@ -8248,6 +8956,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8294,6 +9003,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); @@ -8347,6 +9058,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8373,6 +9085,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); @@ -8406,12 +9120,66 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsCadenceTest : TestBase @@ -8566,18 +9334,34 @@ public void Validation_Works() model.Validate(); } -} -public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void CopyConstructor_Works() { - Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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 +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; value.Validate(); } @@ -8696,6 +9480,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8744,6 +9529,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8766,6 +9552,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) @@ -8820,6 +9607,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8876,6 +9664,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8931,6 +9720,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8956,6 +9746,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) @@ -9010,6 +9801,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9056,6 +9848,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); @@ -9109,6 +9903,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9135,6 +9930,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); @@ -9168,12 +9965,66 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::CumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationCadenceTest : TestBase @@ -9328,6 +10179,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 @@ -9413,17 +10280,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() @@ -9452,20 +10319,17 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, 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() @@ -9474,7 +10338,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::MinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9495,14 +10359,15 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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(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); @@ -9514,6 +10379,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) @@ -9528,12 +10394,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() @@ -9562,12 +10428,13 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = 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 ); @@ -9578,12 +10445,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() @@ -9612,27 +10479,24 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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); - 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() @@ -9641,7 +10505,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::MinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9662,14 +10526,15 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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(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); @@ -9684,6 +10549,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) @@ -9698,12 +10564,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() @@ -9732,6 +10598,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9742,12 +10609,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); @@ -9772,6 +10639,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); @@ -9781,12 +10650,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(); @@ -9795,12 +10664,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, @@ -9813,6 +10682,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9839,6 +10709,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); @@ -9848,12 +10720,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, @@ -9866,34 +10738,82 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::Percent copied = new(model); + + Assert.Equal(model, copied); + } } -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 ); @@ -9903,20 +10823,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); @@ -9925,48 +10845,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 ); @@ -9977,91 +10887,45 @@ 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" }; + var model = new Subscriptions::PercentConfig { Percent = 0 }; 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() + public void CopyConstructor_Works() { - var model = new Subscriptions::MinimumConfig - { - MinimumAmount = "minimum_amount", + var model = new Subscriptions::PercentConfig { Percent = 0 }; - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + Subscriptions::PercentConfig copied = new(model); - model.Validate(); + Assert.Equal(model, copied); } } -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"), @@ -10072,7 +10936,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::MinimumConversionRateConfig value = new SharedTieredConversionRateConfig() + Subscriptions::PercentConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -10092,13 +10956,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 ); @@ -10109,7 +10973,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::MinimumConversionRateConfig value = new SharedTieredConversionRateConfig() + Subscriptions::PercentConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -10124,7 +10988,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10133,17 +10997,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() @@ -10172,16 +11041,22 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, 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() @@ -10190,7 +11065,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::EventOutputConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10211,14 +11086,15 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -10230,6 +11106,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) @@ -10244,12 +11121,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() @@ -10278,12 +11160,13 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = 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 ); @@ -10294,12 +11177,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() @@ -10328,23 +11216,29 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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); - 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() @@ -10353,7 +11247,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::EventOutputConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10374,14 +11268,15 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -10396,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) @@ -10410,12 +11306,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() @@ -10444,6 +11345,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10454,12 +11356,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); @@ -10484,6 +11391,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); @@ -10493,12 +11402,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(); @@ -10507,12 +11421,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, @@ -10525,6 +11444,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -10551,6 +11471,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); @@ -10560,12 +11482,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, @@ -10578,34 +11505,87 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::EventOutput copied = new(model); + + Assert.Equal(model, copied); + } } -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 ); @@ -10615,20 +11595,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); @@ -10637,38 +11617,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 ); @@ -10679,35 +11673,114 @@ 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; - - Assert.Equal(expectedPercent, deserialized.Percent); - } + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; + + Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + } [Fact] public void Validation_Works() { - var model = new Subscriptions::PercentConfig { Percent = 0 }; + var model = new Subscriptions::EventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Subscriptions::EventOutputConfig { UnitRatingKey = "x" }; + + Assert.Null(model.DefaultUnitRate); + Assert.False(model.RawData.ContainsKey("default_unit_rate")); + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Subscriptions::EventOutputConfig { UnitRatingKey = "x" }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::EventOutputConfig + { + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, + }; + + Assert.Null(model.DefaultUnitRate); + Assert.True(model.RawData.ContainsKey("default_unit_rate")); + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Subscriptions::EventOutputConfig + { + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, + }; model.Validate(); } + + [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 PercentConversionRateConfigTest : TestBase +public class EventOutputConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::PercentConversionRateConfig value = new SharedUnitConversionRateConfig() + Subscriptions::EventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), @@ -10718,36 +11791,38 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::PercentConversionRateConfig value = new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + 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::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 - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -10755,196 +11830,181 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::PercentConversionRateConfig value = new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + Subscriptions::EventOutputConversionRateConfig 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, + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class ExternalMarketplaceTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::ExternalMarketplace.Google)] + [InlineData(Subscriptions::ExternalMarketplace.Aws)] + [InlineData(Subscriptions::ExternalMarketplace.Azure)] + public void Validation_Works(Subscriptions::ExternalMarketplace rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Subscriptions::ExternalMarketplace.Google)] + [InlineData(Subscriptions::ExternalMarketplace.Aws)] + [InlineData(Subscriptions::ExternalMarketplace.Azure)] + public void SerializationRoundtrip_Works(Subscriptions::ExternalMarketplace rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class EventOutputTest : TestBase +public class RemoveAdjustmentTest : TestBase { [Fact] public void FieldRoundtrip_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", - }; + var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; - 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, 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(); + } + + [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 +{ + [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() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; + string expectedPriceID = "h74gfhdjvn7ujokd"; - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(expectedPriceID, model.PriceID); } [Fact] public void SerializationRoundtrip_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", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10955,173 +12015,33 @@ public void SerializationRoundtrip_Works() [Fact] 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", }; 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() - { - 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 expectedPriceID = "h74gfhdjvn7ujokd"; - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedEventOutputConfig, deserialized.EventOutputConfig); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(expectedPriceID, deserialized.PriceID); } [Fact] 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", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_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(); @@ -11130,62 +12050,18 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_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 { }; - 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::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(); } @@ -11193,192 +12069,123 @@ 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 -{ - [Theory] - [InlineData(Subscriptions::EventOutputCadence.Annual)] - [InlineData(Subscriptions::EventOutputCadence.SemiAnnual)] - [InlineData(Subscriptions::EventOutputCadence.Monthly)] - [InlineData(Subscriptions::EventOutputCadence.Quarterly)] - [InlineData(Subscriptions::EventOutputCadence.OneTime)] - [InlineData(Subscriptions::EventOutputCadence.Custom)] - public void Validation_Works(Subscriptions::EventOutputCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(Subscriptions::EventOutputCadence.Annual)] - [InlineData(Subscriptions::EventOutputCadence.SemiAnnual)] - [InlineData(Subscriptions::EventOutputCadence.Monthly)] - [InlineData(Subscriptions::EventOutputCadence.Quarterly)] - [InlineData(Subscriptions::EventOutputCadence.OneTime)] - [InlineData(Subscriptions::EventOutputCadence.Custom)] - public void SerializationRoundtrip_Works(Subscriptions::EventOutputCadence rawValue) + public void CopyConstructor_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + var model = new Subscriptions::RemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + Subscriptions::RemovePrice copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } +} +public class ReplaceAdjustmentTest : TestBase +{ [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void FieldRoundtrip_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 + 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 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, model.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); } [Fact] public void SerializationRoundtrip_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 json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -11389,879 +12196,937 @@ public void SerializationRoundtrip_Works() [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(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_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")); - } + 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", + }; - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::EventOutputConfig { UnitRatingKey = "x" }; + Subscriptions::ReplaceAdjustment copied = new(model); - model.Validate(); + Assert.Equal(model, copied); } +} +public class ReplaceAdjustmentAdjustmentTest : TestBase +{ [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) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } [Fact] - public void InvalidEnumValidationThrows_Works() + public void NewUsageDiscountSerializationRoundtripWorks() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), + 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.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(Subscriptions::ExternalMarketplace.Google)] - [InlineData(Subscriptions::ExternalMarketplace.Aws)] - [InlineData(Subscriptions::ExternalMarketplace.Azure)] - public void SerializationRoundtrip_Works(Subscriptions::ExternalMarketplace rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + 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 ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } -} - -public class RemoveAdjustmentTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; - - string expectedAdjustmentID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedAdjustmentID, model.AdjustmentID); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedAdjustmentID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; - - model.Validate(); - } -} - -public class RemovePriceTest : TestBase -{ - [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() + public void NewMinimumSerializationRoundtripWorks() { - var model = new Subscriptions::RemovePrice + Subscriptions::ReplaceAdjustmentAdjustment value = new NewMinimum() { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", + 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 json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewMaximumSerializationRoundtripWorks() { - var model = new Subscriptions::RemovePrice + Subscriptions::ReplaceAdjustmentAdjustment value = new NewMaximum() { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", + 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(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - string 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(); + Assert.Equal(value, deserialized); } } -public class ReplaceAdjustmentTest : TestBase +public class ReplacePriceTest : 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", + LicenseTypeID = "license_type_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", + MetricParameterOverrides = new Dictionary() { - 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, + { "foo", JsonSerializer.SerializeToElement("bar") }, }, - 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::ReplaceAdjustment - { - Adjustment = new NewPercentageDiscount() + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }, - ReplacesAdjustmentID = "replaces_adjustment_id", + PriceID = "h74gfhdjvn7ujokd", }; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - Subscriptions::ReplaceAdjustmentAdjustment expectedAdjustment = new NewPercentageDiscount() + string expectedReplacesPriceID = "replaces_price_id"; + NewAllocationPrice expectedAllocationPrice = 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", + LicenseTypeID = "license_type_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"; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + 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, + }, + LicenseTypeID = "license_type_id", + 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.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); } [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", + LicenseTypeID = "license_type_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", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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, + 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", + }, + PriceID = "h74gfhdjvn7ujokd", }; - value.Validate(); + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewMaximumValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewMaximum() + var model = new Subscriptions::ReplacePrice { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = [ new() { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.Usage, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 2, + MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + PriceID = "h74gfhdjvn7ujokd", }; - value.Validate(); - } - [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() - { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewPercentageDiscount() + 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() { - 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() - { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewUsageDiscount() + 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"; + Dictionary expectedMetricParameterOverrides = new() { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + 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() { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() - { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewAmountDiscount() - { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() + 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, - }; - 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() + 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, - }; - 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() + 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, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions + LicenseTypeID = "license_type_id", + 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.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.Equal(value, deserialized); + Assert.True( + JsonElement.DeepEquals(value, deserialized.MetricParameterOverrides[item.Key]) + ); + } + Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); + Assert.Equal(expectedPrice, deserialized.Price); + Assert.Equal(expectedPriceID, deserialized.PriceID); } -} -public class ReplacePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void Validation_Works() { var model = new Subscriptions::ReplacePrice { @@ -12287,6 +13152,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -12302,6 +13168,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() { @@ -12338,202 +13208,110 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, PriceID = "h74gfhdjvn7ujokd", }; - string expectedReplacesPriceID = "replaces_price_id"; - NewAllocationPrice expectedAllocationPrice = new() + 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.MetricParameterOverrides); + Assert.False(model.RawData.ContainsKey("metric_parameter_overrides")); + 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(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::ReplacePrice { - 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::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"; + ReplacesPriceID = "replaces_price_id", - 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); + AllocationPrice = null, + Discounts = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + MaximumAmount = null, + MetricParameterOverrides = 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.MetricParameterOverrides); + Assert.True(model.RawData.ContainsKey("metric_parameter_overrides")); + 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 SerializationRoundtrip_Works() + public void OptionalNullablePropertiesSetToNullValidation_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 json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + AllocationPrice = null, + Discounts = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + MaximumAmount = null, + MetricParameterOverrides = null, + MinimumAmount = null, + Price = null, + PriceID = null, + }; - Assert.Equal(model, deserialized); + model.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void CopyConstructor_Works() { var model = new Subscriptions::ReplacePrice { @@ -12559,6 +13337,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -12574,6 +13353,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() { @@ -12610,315 +13393,46 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", 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); + Subscriptions::ReplacePrice copied = new(model); - string expectedReplacesPriceID = "replaces_price_id"; - NewAllocationPrice expectedAllocationPrice = new() + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceTest : TestBase +{ + [Fact] + public void NewSubscriptionUnitValidationWorks() + { + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionUnitPrice() { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }; - List expectedDiscounts = - [ - new() + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }, - ]; - 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(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::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", - }; - - 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(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_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, - }; - - 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() + Currency = "currency", + DimensionalPriceConfiguration = new() { DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", @@ -12932,6 +13446,7 @@ public void NewSubscriptionUnitValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12988,6 +13503,7 @@ public void NewSubscriptionTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13032,6 +13548,7 @@ public void NewSubscriptionBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13084,6 +13601,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13128,6 +13646,7 @@ public void NewSubscriptionPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13177,6 +13696,7 @@ public void NewSubscriptionMatrixValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13231,6 +13751,7 @@ public void NewSubscriptionThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13284,6 +13805,7 @@ public void NewSubscriptionTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13349,6 +13871,7 @@ public void NewSubscriptionTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13402,6 +13925,7 @@ public void NewSubscriptionGroupedTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13466,6 +13990,7 @@ public void NewSubscriptionTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13517,6 +14042,7 @@ public void NewSubscriptionPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13563,6 +14089,7 @@ public void NewSubscriptionUnitWithPercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13618,6 +14145,7 @@ public void NewSubscriptionMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13664,6 +14192,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13710,6 +14239,7 @@ public void NewSubscriptionUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13761,6 +14291,7 @@ public void NewSubscriptionGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13812,6 +14343,7 @@ public void NewSubscriptionBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13864,6 +14396,7 @@ public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13929,6 +14462,7 @@ public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13979,6 +14513,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14037,6 +14572,7 @@ public void NewSubscriptionMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14092,6 +14628,7 @@ public void NewSubscriptionGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14147,6 +14684,7 @@ public void NewSubscriptionMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14178,6 +14716,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -14209,6 +14748,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14274,6 +14814,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14332,6 +14873,7 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14382,55 +14924,13 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; 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() { @@ -14475,6 +14975,7 @@ public void NewSubscriptionMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14518,6 +15019,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14566,6 +15068,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14610,6 +15113,7 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14672,6 +15176,7 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14722,6 +15227,7 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14780,6 +15286,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14830,6 +15337,7 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14885,6 +15393,7 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14945,6 +15454,7 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15004,6 +15514,7 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15075,6 +15586,7 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15134,6 +15646,7 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15204,6 +15717,7 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15261,6 +15775,7 @@ public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15313,6 +15828,7 @@ public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15374,6 +15890,7 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15426,6 +15943,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15478,6 +15996,7 @@ public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15535,6 +16054,7 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15592,6 +16112,7 @@ public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15650,6 +16171,7 @@ public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15721,6 +16243,7 @@ public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks( Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15777,6 +16300,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15841,6 +16365,7 @@ public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15902,6 +16427,7 @@ public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15963,6 +16489,7 @@ public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16000,6 +16527,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -16031,6 +16559,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16102,6 +16631,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtrip Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16166,6 +16696,7 @@ public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16222,6 +16753,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16234,55 +16766,6 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() 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() { @@ -16325,1139 +16808,146 @@ public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() 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); - - 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); + DurationUnit = 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 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, + }, + 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 - ); + 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, + }, + 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 - ); + 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() @@ -17486,19 +16976,26 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum< - string, - Subscriptions::ReplacePricePriceTieredWithProrationCadence - > expectedCadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual; + Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = + new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = + Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -17507,7 +17004,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17528,14 +17025,15 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -17547,6 +17045,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) @@ -17561,14 +17060,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() @@ -17597,13 +17102,14 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -17614,14 +17120,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() @@ -17650,27 +17162,34 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum< - string, - Subscriptions::ReplacePricePriceTieredWithProrationCadence - > expectedCadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual; + Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = + new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + ApiEnum expectedCadence = + Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -17679,7 +17198,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17700,14 +17219,15 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -17722,6 +17242,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) @@ -17736,14 +17257,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() @@ -17772,6 +17299,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17782,14 +17310,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); @@ -17814,6 +17348,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); @@ -17823,14 +17359,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProration + var model = new Subscriptions::ReplacePricePriceBulkWithFilters { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -17839,14 +17381,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, @@ -17859,6 +17407,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17885,6 +17434,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); @@ -17894,14 +17445,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_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, @@ -17914,115 +17471,238 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::ReplacePricePriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceTieredWithProrationCadenceTest : TestBase +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : 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::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 InvalidEnumValidationThrows_Works() + public void SerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + 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" }, + ], + }; - 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::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]); + } + } - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); + [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" }, + ], + }; - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void CopyConstructor_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::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + 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); + Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); } } -public class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - 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::ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - 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 ); @@ -18033,75 +17713,86 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - 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::ReplacePricePriceTieredWithProrationTieredWithProrationConfig + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + PropertyKey = "x", + PropertyValue = "x", }; 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 ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = - new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18112,48 +17803,176 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = - new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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::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(); + } + + [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 +{ + [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; - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = - new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); - model.Validate(); + Assert.Equal(value, deserialized); } } -public class ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase +public class ReplacePricePriceBulkWithFiltersConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18165,7 +17984,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18186,7 +18005,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18194,7 +18013,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18205,7 +18024,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18222,7 +18041,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18231,23 +18050,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() @@ -18276,28 +18091,20 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; ApiEnum< string, - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence - > expectedCadence = - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + Subscriptions::ReplacePricePriceTieredWithProrationCadence + > expectedCadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -18306,7 +18113,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18327,17 +18134,15 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -18349,6 +18154,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) @@ -18363,18 +18169,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() @@ -18403,13 +18205,14 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18420,18 +18223,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() @@ -18460,13 +18259,14 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18474,22 +18274,13 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence - > expectedCadence = - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + Subscriptions::ReplacePricePriceTieredWithProrationCadence + > expectedCadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -18498,7 +18289,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18519,17 +18310,15 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -18544,6 +18333,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) @@ -18558,18 +18348,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() @@ -18598,6 +18384,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18608,18 +18395,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); @@ -18644,6 +18427,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); @@ -18653,18 +18438,14 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_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" }] + ), }; model.Validate(); @@ -18673,18 +18454,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, @@ -18697,6 +18474,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18723,6 +18501,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); @@ -18732,53 +18512,99 @@ 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() + 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [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() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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", }; - model.Validate(); + Subscriptions::ReplacePricePriceTieredWithProration copied = new(model); + + Assert.Equal(model, copied); } } -public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase +public class ReplacePricePriceTieredWithProrationCadenceTest : TestBase { [Theory] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Custom)] public void Validation_Works( - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::ReplacePricePriceTieredWithProrationCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = + ApiEnum value = rawValue; value.Validate(); } @@ -18787,7 +18613,7 @@ public void Validation_Works( public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -18795,23 +18621,23 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceTieredWithProrationCadence.Custom)] public void SerializationRoundtrip_Works( - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::ReplacePricePriceTieredWithProrationCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -18821,58 +18647,144 @@ 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(); + } + + [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 { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18884,55 +18796,63 @@ 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(); } + + [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 ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class ReplacePricePriceTieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18944,7 +18864,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18965,7 +18885,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18973,7 +18893,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18984,7 +18904,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19001,7 +18921,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19010,20 +18930,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", @@ -19055,26 +18975,27 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; ApiEnum< string, - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence > expectedCadence = - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -19085,7 +19006,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19106,13 +19027,14 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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 + expectedGroupedWithMinMaxThresholdsConfig, + model.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); @@ -19128,6 +19050,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) @@ -19142,15 +19065,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", @@ -19182,13 +19105,14 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -19199,15 +19123,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", @@ -19239,13 +19163,14 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19253,20 +19178,20 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence > expectedCadence = - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -19277,7 +19202,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19298,13 +19223,14 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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 + expectedGroupedWithMinMaxThresholdsConfig, + deserialized.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); @@ -19323,6 +19249,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) @@ -19337,15 +19264,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", @@ -19377,6 +19304,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19387,15 +19315,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", @@ -19423,6 +19351,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); @@ -19432,15 +19362,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation + var model = new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -19452,15 +19382,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", @@ -19476,6 +19406,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19502,6 +19433,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); @@ -19511,15 +19444,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", @@ -19535,29 +19468,83 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } -public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase { [Theory] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] public void Validation_Works( - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = + ApiEnum value = rawValue; value.Validate(); } @@ -19566,7 +19553,7 @@ public void Validation_Works( public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -19574,23 +19561,23 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] - [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom)] public void SerializationRoundtrip_Works( - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -19600,58 +19587,58 @@ public void SerializationRoundtrip_Works( public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest +public class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedMaximumCharge, model.MaximumCharge); + Assert.Equal(expectedMinimumCharge, model.MinimumCharge); + Assert.Equal(expectedPerUnitRate, model.PerUnitRate); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -19663,55 +19650,73 @@ 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(); } + + [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 ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19723,7 +19728,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19744,7 +19749,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19752,7 +19757,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19763,7 +19768,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19780,7 +19785,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19789,16 +19794,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, @@ -19828,19 +19839,28 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - Subscriptions::ReplacePricePriceMinimumCadence.Annual; + ApiEnum< + string, + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence + > expectedCadence = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - Subscriptions::ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -19850,7 +19870,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19871,12 +19891,16 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -19890,6 +19914,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) @@ -19904,11 +19929,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, @@ -19938,15 +19969,17 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = 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 - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -19954,11 +19987,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, @@ -19988,26 +20027,36 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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 - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - Subscriptions::ReplacePricePriceMinimumCadence.Annual; + ApiEnum< + string, + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence + > expectedCadence = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - Subscriptions::ReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -20017,7 +20066,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20038,12 +20087,16 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -20060,6 +20113,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) @@ -20074,11 +20128,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, @@ -20108,6 +20168,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20118,11 +20179,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", }; @@ -20148,6 +20215,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); @@ -20157,11 +20226,17 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::ReplacePricePriceMinimum + var model = new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -20171,11 +20246,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, @@ -20189,6 +20270,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20215,6 +20297,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); @@ -20224,11 +20308,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, @@ -20242,27 +20332,84 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; - model.Validate(); + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::ReplacePricePriceCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); } } -public class ReplacePricePriceMinimumCadenceTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationCadenceTest : TestBase { [Theory] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.Quarterly)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.OneTime)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.Custom)] - public void Validation_Works(Subscriptions::ReplacePricePriceMinimumCadence rawValue) + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] + public void Validation_Works( + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence rawValue + ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = + rawValue; value.Validate(); } @@ -20270,7 +20417,7 @@ public void Validation_Works(Subscriptions::ReplacePricePriceMinimumCadence rawV public void InvalidEnumValidationThrows_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); Assert.NotNull(value); @@ -20278,22 +20425,23 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.Annual)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.SemiAnnual)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.Monthly)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.Quarterly)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.OneTime)] - [InlineData(Subscriptions::ReplacePricePriceMinimumCadence.Custom)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Custom)] public void SerializationRoundtrip_Works( - Subscriptions::ReplacePricePriceMinimumCadence rawValue + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = + rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -20303,47 +20451,58 @@ public void SerializationRoundtrip_Works( public void InvalidEnumSerializationRoundtrip_Works() { var value = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } } -public class ReplacePricePriceMinimumMinimumConfigTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; + var model = + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -20354,98 +20513,74 @@ 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", - }; + var model = + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_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() + public void CopyConstructor_Works() { - var model = new Subscriptions::ReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", + var model = + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class ReplacePricePriceMinimumConversionRateConfigTest : TestBase +public class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20457,7 +20592,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20478,7 +20613,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20486,7 +20621,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20497,7 +20632,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20514,7 +20649,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20562,6 +20697,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20601,6 +20737,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -20620,6 +20757,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) @@ -20668,6 +20806,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20718,6 +20857,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20764,6 +20904,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -20786,6 +20927,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) @@ -20834,6 +20976,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20874,6 +21017,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); @@ -20915,6 +21060,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20941,6 +21087,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); @@ -20968,12 +21116,60 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::ReplacePricePricePercent copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePricePercentCadenceTest : TestBase @@ -21092,6 +21288,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 @@ -21221,6 +21427,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21266,6 +21473,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -21285,6 +21493,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) @@ -21338,6 +21547,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21393,6 +21603,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21445,6 +21656,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -21467,6 +21679,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) @@ -21520,6 +21733,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21565,6 +21779,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); @@ -21616,6 +21832,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -21642,6 +21859,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); @@ -21674,12 +21893,65 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::ReplacePricePriceEventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class ReplacePricePriceEventOutputCadenceTest : TestBase @@ -21882,6 +22154,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/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/SubscriptionFetchCostsResponseTest.cs b/src/Orb.Tests/Models/Subscriptions/SubscriptionFetchCostsResponseTest.cs index 7e5ba5e46..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", @@ -875,4 +917,157 @@ 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"], + }, + ], + 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", + }, + }, + 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/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/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/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/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/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..4da3e6cac 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, @@ -58,6 +59,10 @@ public void FieldRoundtrip_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -95,6 +100,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -149,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"], }, @@ -191,6 +201,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -207,6 +218,10 @@ public void FieldRoundtrip_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -243,6 +258,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -297,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"], }, @@ -418,6 +438,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -434,6 +455,10 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -471,6 +496,7 @@ public void OptionalNullableParamsUnsetAreNotSet_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -523,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"], }, @@ -576,6 +606,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -592,6 +623,10 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -629,6 +664,7 @@ public void OptionalNullableParamsSetToNullAreSetToNull_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -681,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"], }, @@ -720,6 +760,175 @@ 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", + LicenseTypeID = "license_type_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, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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, + }, + LicenseTypeID = "license_type_id", + 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, + }, + ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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 @@ -751,6 +960,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -767,6 +977,10 @@ public void FieldRoundtrip_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -803,6 +1017,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -833,6 +1048,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; bool expectedCanDeferBilling = true; @@ -849,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() { @@ -885,6 +1105,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string expectedPriceID = "h74gfhdjvn7ujokd"; @@ -915,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); @@ -953,6 +1182,7 @@ public void SerializationRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -969,6 +1199,10 @@ public void SerializationRoundtrip_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -1005,6 +1239,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -1047,6 +1282,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -1063,6 +1299,10 @@ public void FieldRoundtripThroughSerialization_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -1099,6 +1339,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -1136,6 +1377,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }; bool expectedCanDeferBilling = true; @@ -1152,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() { @@ -1188,6 +1434,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string expectedPriceID = "h74gfhdjvn7ujokd"; @@ -1218,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); @@ -1256,6 +1516,7 @@ public void Validation_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, CanDeferBilling = true, @@ -1272,6 +1533,10 @@ public void Validation_Works() }, ], MaximumAmount = 0, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, MinimumAmount = 0, Price = new NewFloatingUnitPrice() { @@ -1308,6 +1573,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }, PriceID = "h74gfhdjvn7ujokd", @@ -1341,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); @@ -1377,6 +1645,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Filter = null, FixedFeeQuantityTransitions = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, Price = null, PriceID = null, @@ -1399,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); @@ -1424,6 +1695,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Filter = null, FixedFeeQuantityTransitions = null, MaximumAmount = null, + MetricParameterOverrides = null, MinimumAmount = null, Price = null, PriceID = null, @@ -1432,68 +1704,164 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } -} - -public class StartDateTest : TestBase -{ - [Fact] - public void DateTimeValidationWorks() - { - Subscriptions::StartDate value = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - value.Validate(); - } - - [Fact] - public void BillingCycleRelativeValidationWorks() - { - Subscriptions::StartDate value = BillingCycleRelativeDate.StartOfTerm; - value.Validate(); - } - - [Fact] - public void DateTimeSerializationRoundtripWorks() - { - Subscriptions::StartDate value = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void BillingCycleRelativeSerializationRoundtripWorks() - { - Subscriptions::StartDate value = BillingCycleRelativeDate.StartOfTerm; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class DiscountTest : TestBase -{ - [Fact] - public void AmountValidationWorks() - { - Subscriptions::Discount value = new Subscriptions::Amount(0); - value.Validate(); - } [Fact] - public void PercentageValidationWorks() + public void CopyConstructor_Works() { - Subscriptions::Discount value = new Subscriptions::Percentage(0.15); - value.Validate(); - } - - [Fact] + 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", + LicenseTypeID = "license_type_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, + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }, + PriceID = "h74gfhdjvn7ujokd", + UsageCustomerIds = ["string"], + }; + + Subscriptions::Add copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class StartDateTest : TestBase +{ + [Fact] + public void DateTimeValidationWorks() + { + Subscriptions::StartDate value = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + value.Validate(); + } + + [Fact] + public void BillingCycleRelativeValidationWorks() + { + Subscriptions::StartDate value = BillingCycleRelativeDate.StartOfTerm; + value.Validate(); + } + + [Fact] + public void DateTimeSerializationRoundtripWorks() + { + Subscriptions::StartDate value = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void BillingCycleRelativeSerializationRoundtripWorks() + { + Subscriptions::StartDate value = BillingCycleRelativeDate.StartOfTerm; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class DiscountTest : TestBase +{ + [Fact] + public void AmountValidationWorks() + { + Subscriptions::Discount value = new Subscriptions::Amount(0); + value.Validate(); + } + + [Fact] + public void PercentageValidationWorks() + { + Subscriptions::Discount value = new Subscriptions::Percentage(0.15); + value.Validate(); + } + + [Fact] public void UsageValidationWorks() { Subscriptions::Discount value = new Subscriptions::Usage(2); @@ -1594,6 +1962,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 @@ -1650,6 +2028,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 @@ -1706,6 +2094,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 @@ -1821,6 +2219,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 @@ -1863,6 +2275,7 @@ public void NewFloatingUnitValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1918,6 +2331,7 @@ public void NewFloatingTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1961,6 +2375,7 @@ public void NewFloatingBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2011,6 +2426,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2054,6 +2470,7 @@ public void NewFloatingPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2102,6 +2519,7 @@ public void NewFloatingMatrixValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2153,6 +2571,7 @@ public void NewFloatingThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2204,6 +2623,7 @@ public void NewFloatingTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2266,6 +2686,7 @@ public void NewFloatingTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2317,6 +2738,7 @@ public void NewFloatingGroupedTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2378,6 +2800,7 @@ public void NewFloatingTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2426,6 +2849,7 @@ public void NewFloatingPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2469,6 +2893,7 @@ public void NewFloatingUnitWithPercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2518,6 +2943,7 @@ public void NewFloatingMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2563,6 +2989,7 @@ public void NewFloatingTieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2606,6 +3033,7 @@ public void NewFloatingUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2654,6 +3082,7 @@ public void NewFloatingGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2702,6 +3131,7 @@ public void NewFloatingBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2751,6 +3181,7 @@ public void NewFloatingGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2809,6 +3240,7 @@ public void NewFloatingGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2857,6 +3289,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2912,6 +3345,7 @@ public void NewFloatingMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2964,6 +3398,7 @@ public void NewFloatingGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3016,6 +3451,7 @@ public void NewFloatingMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3045,6 +3481,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -3075,6 +3512,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3137,6 +3575,7 @@ public void NewFloatingScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3192,6 +3631,7 @@ public void NewFloatingCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3240,48 +3680,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - Metadata = new Dictionary() { { "foo", "string" } }, - }; - 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, - }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3325,6 +3724,7 @@ public void NewFloatingMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3367,6 +3767,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3414,6 +3815,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3457,6 +3859,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); @@ -3518,6 +3921,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); @@ -3567,6 +3971,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); @@ -3623,6 +4028,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); @@ -3672,6 +4078,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); @@ -3726,6 +4133,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); @@ -3783,6 +4191,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); @@ -3840,6 +4249,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); @@ -3908,6 +4318,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); @@ -3965,6 +4376,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); @@ -4032,6 +4444,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); @@ -4086,6 +4499,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); @@ -4135,6 +4549,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); @@ -4190,6 +4605,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); @@ -4241,6 +4657,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); @@ -4290,6 +4707,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); @@ -4344,6 +4762,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); @@ -4398,6 +4817,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); @@ -4453,6 +4873,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); @@ -4517,6 +4938,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); @@ -4571,6 +4993,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); @@ -4632,6 +5055,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); @@ -4690,6 +5114,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); @@ -4748,6 +5173,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); @@ -4783,6 +5209,7 @@ public void NewFloatingScalableMatrixWithUnitPricingSerializationRoundtripWorks( }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -4813,6 +5240,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); @@ -4881,6 +5309,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); @@ -4942,6 +5371,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); @@ -4996,6 +5426,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); @@ -5008,14 +5439,15 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void NewFloatingMinimumCompositeSerializationRoundtripWorks() { - Subscriptions::PriceModel value = new Subscriptions::PriceModelMinimum() + Subscriptions::PriceModel value = new NewFloatingMinimumCompositePrice() { - Cadence = Subscriptions::PriceModelMinimumCadence.Annual, + Cadence = NewFloatingMinimumCompositePriceCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = NewFloatingMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5044,6 +5476,7 @@ public void MinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -5056,16 +5489,15 @@ public void MinimumSerializationRoundtripWorks() } [Fact] - public void NewFloatingMinimumCompositeSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { - Subscriptions::PriceModel value = new NewFloatingMinimumCompositePrice() + Subscriptions::PriceModel value = new Subscriptions::PriceModelPercent() { - Cadence = NewFloatingMinimumCompositePriceCadence.Annual, + Cadence = Subscriptions::PriceModelPercentCadence.Annual, Currency = "currency", ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = NewFloatingMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5093,6 +5525,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); @@ -5105,15 +5538,20 @@ public void NewFloatingMinimumCompositeSerializationRoundtripWorks() } [Fact] - public void PercentSerializationRoundtripWorks() + public void EventOutputSerializationRoundtripWorks() { - Subscriptions::PriceModel value = new Subscriptions::PriceModelPercent() + Subscriptions::PriceModel value = new Subscriptions::PriceModelEventOutput() { - Cadence = Subscriptions::PriceModelPercentCadence.Annual, + Cadence = Subscriptions::PriceModelEventOutputCadence.Annual, Currency = "currency", + 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() @@ -5141,6 +5579,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); @@ -5151,67 +5590,14 @@ public void PercentSerializationRoundtripWorks() Assert.Equal(value, deserialized); } +} +public class PriceModelBulkWithFiltersTest : TestBase +{ [Fact] - public void EventOutputSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Subscriptions::PriceModel value = 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" } }, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class PriceModelBulkWithFiltersTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::PriceModelBulkWithFilters + var model = new Subscriptions::PriceModelBulkWithFilters { BulkWithFiltersConfig = new() { @@ -5253,6 +5639,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5300,6 +5687,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); @@ -5318,6 +5706,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) @@ -5373,6 +5762,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5430,6 +5820,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5484,6 +5875,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); @@ -5505,6 +5897,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) @@ -5560,6 +5953,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5606,6 +6000,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")); } @@ -5662,6 +6058,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5685,6 +6082,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")); } @@ -5718,11 +6117,66 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + Subscriptions::PriceModelBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelBulkWithFiltersBulkWithFiltersConfigTest : TestBase @@ -5843,6 +6297,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 @@ -5917,6 +6389,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 @@ -6041,6 +6527,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 @@ -6235,6 +6735,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6284,6 +6785,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); @@ -6305,6 +6807,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) @@ -6358,6 +6861,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6414,6 +6918,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6471,6 +6976,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); @@ -6495,6 +7001,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) @@ -6548,6 +7055,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6592,6 +7100,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")); } @@ -6644,6 +7154,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6667,6 +7178,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")); } @@ -6698,11 +7211,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } + + [Fact] + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + Subscriptions::PriceModelGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelGroupedWithMinMaxThresholdsCadenceTest : TestBase @@ -6865,6 +7431,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 @@ -6995,6 +7579,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7044,6 +7629,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); @@ -7065,6 +7651,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) @@ -7118,6 +7705,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7174,6 +7762,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7231,6 +7820,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); @@ -7255,6 +7845,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) @@ -7308,6 +7899,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7352,6 +7944,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")); } @@ -7404,6 +7998,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7427,6 +8022,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")); } @@ -7458,11 +8055,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + Subscriptions::PriceModelCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelCumulativeGroupedAllocationCadenceTest : TestBase @@ -7606,749 +8256,51 @@ public void FieldRoundtripThroughSerialization_Works() 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 Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; - - model.Validate(); - } -} - -public class PriceModelCumulativeGroupedAllocationConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } - - [Fact] - public void UnitSerializationRoundtripWorks() - { - Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig 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::PriceModelCumulativeGroupedAllocationConversionRateConfig 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 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(); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void Validation_Works() { - var model = new Subscriptions::PriceModelMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + var model = + new Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() + public void CopyConstructor_Works() { - var model = new Subscriptions::PriceModelMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", + var model = + new Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class PriceModelMinimumConversionRateConfigTest : TestBase +public class PriceModelCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::PriceModelMinimumConversionRateConfig value = + Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8360,7 +8312,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::PriceModelMinimumConversionRateConfig value = + Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8381,7 +8333,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::PriceModelMinimumConversionRateConfig value = + Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8389,7 +8341,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8400,7 +8352,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::PriceModelMinimumConversionRateConfig value = + Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8417,7 +8369,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8465,6 +8417,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8503,6 +8456,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); @@ -8521,6 +8475,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) @@ -8568,6 +8523,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8617,6 +8573,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8662,6 +8619,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); @@ -8683,6 +8641,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) @@ -8730,6 +8689,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8768,6 +8728,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")); } @@ -8808,6 +8770,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8831,6 +8794,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")); } @@ -8856,11 +8821,58 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + Subscriptions::PriceModelPercent copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelPercentCadenceTest : TestBase @@ -8977,6 +8989,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 @@ -9106,6 +9128,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9149,6 +9172,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); @@ -9167,6 +9191,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) @@ -9219,6 +9244,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9273,6 +9299,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9323,6 +9350,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); @@ -9344,6 +9372,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) @@ -9396,6 +9425,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9439,6 +9469,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")); } @@ -9489,6 +9521,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -9512,6 +9545,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")); } @@ -9542,11 +9577,63 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + Subscriptions::PriceModelEventOutput copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelEventOutputCadenceTest : TestBase @@ -9747,6 +9834,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 @@ -10102,6 +10204,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 @@ -10532,6 +10669,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"], }; @@ -10551,6 +10692,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" ); @@ -10573,6 +10718,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); @@ -10600,6 +10753,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"], }; @@ -10631,6 +10788,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"], }; @@ -10657,6 +10818,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" ); @@ -10679,6 +10844,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); @@ -10706,6 +10884,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"], }; @@ -10731,6 +10913,10 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, UsageCustomerIds = ["string"], }; @@ -10756,6 +10942,10 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, UsageCustomerIds = ["string"], }; @@ -10780,6 +10970,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 @@ -10808,6 +11002,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 @@ -10836,6 +11034,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")); } @@ -10865,6 +11065,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() EndDate = null, Filter = null, FixedFeeQuantityTransitions = null, + MetricParameterOverrides = null, UsageCustomerIds = null, }; @@ -10878,6 +11079,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")); } @@ -10895,11 +11098,43 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() EndDate = null, Filter = null, FixedFeeQuantityTransitions = null, + MetricParameterOverrides = null, UsageCustomerIds = null, }; 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, + }, + ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + UsageCustomerIds = ["string"], + }; + + Subscriptions::Edit copied = new(model); + + Assert.Equal(model, copied); + } } public class EditEndDateTest : TestBase @@ -11017,6 +11252,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 @@ -11258,6 +11507,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/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..21ef5f879 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 = @@ -87,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() @@ -125,6 +130,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -212,6 +218,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -227,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() { @@ -264,6 +275,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -334,6 +346,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -349,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() @@ -386,6 +403,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -477,6 +495,7 @@ public void FieldRoundtrip_Works() }, ], ItemID = "item_id", + LicenseTypeID = "license_type_id", PerUnitCostBasis = "per_unit_cost_basis", }, Discounts = @@ -492,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() { @@ -528,6 +551,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }, @@ -783,2231 +807,1101 @@ public void Url_Works() url ); } -} - -public class SubscriptionSchedulePlanChangeParamsChangeOptionTest : TestBase -{ - [Theory] - [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.RequestedDate)] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.EndOfSubscriptionTerm - )] - [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.Immediate)] - public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.RequestedDate)] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.EndOfSubscriptionTerm - )] - [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.Immediate)] - public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = - rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } -} -public class SubscriptionSchedulePlanChangeParamsAddAdjustmentTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + var parameters = new Subscriptions::SubscriptionSchedulePlanChangeParams { - 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() + SubscriptionID = "subscription_id", + ChangeOption = + Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.RequestedDate, + AddAdjustments = + [ + new() + { + Adjustment = new NewPercentageDiscount() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + 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, }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment expectedAdjustment = - new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }, + ], + AddPrices = + [ + new() + { + AllocationPrice = new() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - long expectedPlanPhaseOrder = 0; - DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedEndDate, model.EndDate); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - Assert.Equal(expectedStartDate, model.StartDate); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() + 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", + MetricParameterOverrides = new Dictionary() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + { "foo", JsonSerializer.SerializeToElement("bar") }, }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment expectedAdjustment = - new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - long expectedPlanPhaseOrder = 0; - DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedEndDate, deserialized.EndDate); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedStartDate, deserialized.StartDate); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - }; - - Assert.Null(model.EndDate); - Assert.False(model.RawData.ContainsKey("end_date")); - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.StartDate); - Assert.False(model.RawData.ContainsKey("start_date")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - - EndDate = null, - PlanPhaseOrder = null, - StartDate = null, - }; - - Assert.Null(model.EndDate); - Assert.True(model.RawData.ContainsKey("end_date")); - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.StartDate); - Assert.True(model.RawData.ContainsKey("start_date")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - - EndDate = null, - PlanPhaseOrder = null, - StartDate = null, - }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustmentTest : TestBase -{ - [Fact] - public void NewPercentageDiscountValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewUsageDiscountValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewUsageDiscount() - { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewAmountDiscountValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewAmountDiscount() - { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewMinimumValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewMinimum() - { - AdjustmentType = NewMinimumAdjustmentType.Minimum, - ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewMaximumValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewMaximum() - { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.Usage, - }; - value.Validate(); - } - - [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewUsageDiscount() - { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewAmountDiscount() - { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewMinimumSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewMinimum() - { - AdjustmentType = NewMinimumAdjustmentType.Minimum, - ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewMaximumSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewMaximum() - { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddPriceTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - ExternalPriceID = "external_price_id", - MaximumAmount = "1.23", - MinimumAmount = "1.23", - PlanPhaseOrder = 0, - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }; - List expectedDiscounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ]; - DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - string expectedExternalPriceID = "external_price_id"; - string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; - long expectedPlanPhaseOrder = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice expectedPrice = - new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string expectedPriceID = "h74gfhdjvn7ujokd"; - DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - - Assert.Equal(expectedAllocationPrice, model.AllocationPrice); - Assert.NotNull(model.Discounts); - Assert.Equal(expectedDiscounts.Count, model.Discounts.Count); - for (int i = 0; i < expectedDiscounts.Count; i++) - { - Assert.Equal(expectedDiscounts[i], model.Discounts[i]); - } - Assert.Equal(expectedEndDate, model.EndDate); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedMaximumAmount, model.MaximumAmount); - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - Assert.Equal(expectedPrice, model.Price); - Assert.Equal(expectedPriceID, model.PriceID); - Assert.Equal(expectedStartDate, model.StartDate); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - ExternalPriceID = "external_price_id", - MaximumAmount = "1.23", - MinimumAmount = "1.23", - PlanPhaseOrder = 0, - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() + MinimumAmount = "1.23", + PlanPhaseOrder = 0, + Price = new Subscriptions::NewSubscriptionUnitPrice() { - 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, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }, + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + ], + AlignBillingWithPlanChangeDate = true, + AutoCollection = true, + BillingCycleAlignment = Subscriptions::BillingCycleAlignment.Unchanged, + BillingCycleAnchorConfiguration = new() { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, + Day = 1, + Month = 1, + Year = 0, }, - ExpiresAtEndOfCadence = true, - Filters = + 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() { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }; - List expectedDiscounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ]; - DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - string expectedExternalPriceID = "external_price_id"; - string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; - long expectedPlanPhaseOrder = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice expectedPrice = - new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string expectedPriceID = "h74gfhdjvn7ujokd"; - DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - - Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); - Assert.NotNull(deserialized.Discounts); - Assert.Equal(expectedDiscounts.Count, deserialized.Discounts.Count); - for (int i = 0; i < expectedDiscounts.Count; i++) - { - Assert.Equal(expectedDiscounts[i], deserialized.Discounts[i]); - } - Assert.Equal(expectedEndDate, deserialized.EndDate); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedPrice, deserialized.Price); - Assert.Equal(expectedPriceID, deserialized.PriceID); - Assert.Equal(expectedStartDate, deserialized.StartDate); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + ReplacePrices = + [ + new() { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_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", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + PriceID = "h74gfhdjvn7ujokd", }, ], - 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"), + TrialDurationDays = 0, + UsageCustomerIds = ["string"], }; - model.Validate(); + Subscriptions::SubscriptionSchedulePlanChangeParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsChangeOptionTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.RequestedDate)] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.EndOfSubscriptionTerm + )] + [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.Immediate)] + public void Validation_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = + rawValue; + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void InvalidEnumValidationThrows_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice { }; + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - Assert.Null(model.AllocationPrice); - Assert.False(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.False(model.RawData.ContainsKey("discounts")); - Assert.Null(model.EndDate); - Assert.False(model.RawData.ContainsKey("end_date")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.MaximumAmount); - Assert.False(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.False(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.Price); - Assert.False(model.RawData.ContainsKey("price")); - Assert.Null(model.PriceID); - Assert.False(model.RawData.ContainsKey("price_id")); - Assert.Null(model.StartDate); - Assert.False(model.RawData.ContainsKey("start_date")); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.RequestedDate)] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.EndOfSubscriptionTerm + )] + [InlineData(Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption.Immediate)] + public void SerializationRoundtrip_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsChangeOption rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = + rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice { }; + 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 SubscriptionSchedulePlanChangeParamsAddAdjustmentTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment { - AllocationPrice = null, - Discounts = null, - EndDate = null, - ExternalPriceID = null, - MaximumAmount = null, - MinimumAmount = null, - PlanPhaseOrder = null, - Price = null, - PriceID = null, - StartDate = null, + 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"), }; - Assert.Null(model.AllocationPrice); - Assert.True(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.True(model.RawData.ContainsKey("discounts")); - Assert.Null(model.EndDate); - Assert.True(model.RawData.ContainsKey("end_date")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.MaximumAmount); - Assert.True(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.True(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); - Assert.Null(model.Price); - Assert.True(model.RawData.ContainsKey("price")); - Assert.Null(model.PriceID); - Assert.True(model.RawData.ContainsKey("price_id")); - Assert.Null(model.StartDate); - Assert.True(model.RawData.ContainsKey("start_date")); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment expectedAdjustment = + new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + long expectedPlanPhaseOrder = 0; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(expectedStartDate, model.StartDate); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment { - AllocationPrice = null, - Discounts = null, - EndDate = null, - ExternalPriceID = null, - MaximumAmount = null, - MinimumAmount = null, - PlanPhaseOrder = null, - Price = null, - PriceID = null, - StartDate = null, + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), }; - model.Validate(); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTest : TestBase -{ [Fact] - public void NewSubscriptionUnitValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment expectedAdjustment = + new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; - value.Validate(); + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + long expectedPlanPhaseOrder = 0; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedStartDate, deserialized.StartDate); } [Fact] - public void NewSubscriptionTieredValidationWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() - { - Tiers = - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ], - Prorated = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + PlanPhaseOrder = 0, + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + model.Validate(); } [Fact] - public void NewSubscriptionBulkValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice 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"), - }, + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + }; + + Assert.Null(model.EndDate); + Assert.False(model.RawData.ContainsKey("end_date")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.StartDate); + Assert.False(model.RawData.ContainsKey("start_date")); } [Fact] - public void BulkWithFiltersValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + }; + + model.Validate(); } [Fact] - public void NewSubscriptionPackageValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionPackagePrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, - Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + + EndDate = null, + PlanPhaseOrder = null, + StartDate = null, + }; + + Assert.Null(model.EndDate); + Assert.True(model.RawData.ContainsKey("end_date")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.StartDate); + Assert.True(model.RawData.ContainsKey("start_date")); } [Fact] - public void NewSubscriptionMatrixValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, - ItemID = "item_id", - MatrixConfig = new() - { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + + EndDate = null, + PlanPhaseOrder = null, + StartDate = null, + }; + + model.Validate(); } [Fact] - public void NewSubscriptionThresholdTotalAmountValidationWorks() + public void CopyConstructor_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() - { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + EndDate = 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 +{ [Fact] - public void NewSubscriptionTieredPackageValidationWorks() + public void NewPercentageDiscountValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionTieredWithMinimumValidationWorks() + public void NewUsageDiscountValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewUsageDiscount() { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() - { - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - HideZeroAmountTiers = true, - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewUsageDiscountPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredValidationWorks() + public void NewAmountDiscountValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice 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"), - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewAmountDiscount() + { + AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageWithMinimumValidationWorks() + public void NewMinimumValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewMinimum() { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + AdjustmentType = NewMinimumAdjustmentType.Minimum, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() - { - PackageSize = 0, - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionPackageWithAllocationValidationWorks() + public void NewMaximumValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewMaximum() { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionUnitWithPercentValidationWorks() + public void NewPercentageDiscountSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, - Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewUsageDiscountSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewUsageDiscount() + { + AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewUsageDiscountPriceType.Usage, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionMatrixWithAllocationValidationWorks() + public void NewAmountDiscountSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewAmountDiscount() { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() - { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void TieredWithProrationValidationWorks() + public void NewMinimumSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewMinimum() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + AdjustmentType = NewMinimumAdjustmentType.Minimum, ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionUnitWithProrationValidationWorks() + public void NewMaximumSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = + new NewMaximum() { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, - Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } +} +public class SubscriptionSchedulePlanChangeParamsAddPriceTest : TestBase +{ [Fact] - public void NewSubscriptionGroupedAllocationValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + { + AllocationPrice = new() { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() + 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", + 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", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + MinimumAmount = "1.23", + PlanPhaseOrder = 0, + Price = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3036,29 +1930,65 @@ public void NewSubscriptionGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); - } + }, + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; - [Fact] - public void NewSubscriptionBulkWithProrationValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + NewAllocationPrice expectedAllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }; + List expectedDiscounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ]; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedExternalPriceID = "external_price_id"; + string expectedMaximumAmount = "1.23"; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedMinimumAmount = "1.23"; + long expectedPlanPhaseOrder = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice 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() @@ -3087,30 +2017,93 @@ public void NewSubscriptionBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + string expectedPriceID = "h74gfhdjvn7ujokd"; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedAllocationPrice, model.AllocationPrice); + Assert.NotNull(model.Discounts); + Assert.Equal(expectedDiscounts.Count, model.Discounts.Count); + for (int i = 0; i < expectedDiscounts.Count; i++) + { + Assert.Equal(expectedDiscounts[i], model.Discounts[i]); + } + Assert.Equal(expectedEndDate, model.EndDate); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedMaximumAmount, model.MaximumAmount); + Assert.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); + Assert.Equal(expectedPriceID, model.PriceID); + Assert.Equal(expectedStartDate, model.StartDate); } [Fact] - public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + { + AllocationPrice = new() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + LicenseTypeID = "license_type_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", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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() @@ -3139,94 +2132,79 @@ public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); + }, + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + { + AllocationPrice = new() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() - { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() - { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", - }, - ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, - ], - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + DurationUnit = CustomExpirationDurationUnit.Day, }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void GroupedWithMinMaxThresholdsValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalPriceID = "external_price_id", + MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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() @@ -3255,36 +2233,73 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); - } + }, + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; - [Fact] - public void NewSubscriptionMatrixWithDisplayNameValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + NewAllocationPrice expectedAllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - Cadence = Subscriptions::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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }; + List expectedDiscounts = + [ + new() + { + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, + }, + ]; + DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + string expectedExternalPriceID = "external_price_id"; + string expectedMaximumAmount = "1.23"; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + string expectedMinimumAmount = "1.23"; + long expectedPlanPhaseOrder = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice expectedPrice = + new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3313,33 +2328,98 @@ public void NewSubscriptionMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + string expectedPriceID = "h74gfhdjvn7ujokd"; + DateTimeOffset expectedStartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); + + Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); + Assert.NotNull(deserialized.Discounts); + Assert.Equal(expectedDiscounts.Count, deserialized.Discounts.Count); + for (int i = 0; i < expectedDiscounts.Count; i++) + { + Assert.Equal(expectedDiscounts[i], deserialized.Discounts[i]); + } + Assert.Equal(expectedEndDate, deserialized.EndDate); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedMaximumAmount, deserialized.MaximumAmount); + Assert.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); + Assert.Equal(expectedPriceID, deserialized.PriceID); + Assert.Equal(expectedStartDate, deserialized.StartDate); } [Fact] - public void NewSubscriptionGroupedTieredPackageValidationWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + { + 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", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + LicenseTypeID = "license_type_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", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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() @@ -3368,95 +2448,172 @@ public void NewSubscriptionGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); + }, + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice { }; + + Assert.Null(model.AllocationPrice); + Assert.False(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.Discounts); + Assert.False(model.RawData.ContainsKey("discounts")); + Assert.Null(model.EndDate); + Assert.False(model.RawData.ContainsKey("end_date")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.MaximumAmount); + Assert.False(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MetricParameterOverrides); + Assert.False(model.RawData.ContainsKey("metric_parameter_overrides")); + Assert.Null(model.MinimumAmount); + Assert.False(model.RawData.ContainsKey("minimum_amount")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.Price); + Assert.False(model.RawData.ContainsKey("price")); + Assert.Null(model.PriceID); + Assert.False(model.RawData.ContainsKey("price_id")); + Assert.Null(model.StartDate); + Assert.False(model.RawData.ContainsKey("start_date")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice { }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + { + AllocationPrice = null, + Discounts = null, + EndDate = null, + ExternalPriceID = null, + MaximumAmount = null, + MetricParameterOverrides = null, + MinimumAmount = null, + PlanPhaseOrder = null, + Price = null, + PriceID = null, + StartDate = null, + }; + + Assert.Null(model.AllocationPrice); + Assert.True(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.Discounts); + Assert.True(model.RawData.ContainsKey("discounts")); + Assert.Null(model.EndDate); + Assert.True(model.RawData.ContainsKey("end_date")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.MaximumAmount); + Assert.True(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MetricParameterOverrides); + Assert.True(model.RawData.ContainsKey("metric_parameter_overrides")); + Assert.Null(model.MinimumAmount); + Assert.True(model.RawData.ContainsKey("minimum_amount")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.Price); + Assert.True(model.RawData.ContainsKey("price")); + Assert.Null(model.PriceID); + Assert.True(model.RawData.ContainsKey("price_id")); + Assert.Null(model.StartDate); + Assert.True(model.RawData.ContainsKey("start_date")); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + { + AllocationPrice = null, + Discounts = null, + EndDate = null, + ExternalPriceID = null, + MaximumAmount = null, + MetricParameterOverrides = null, + MinimumAmount = null, + PlanPhaseOrder = null, + Price = null, + PriceID = null, + StartDate = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice + { + AllocationPrice = new() { - 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() + 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", + LicenseTypeID = "license_type_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 NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + ], + EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + ExternalPriceID = "external_price_id", + MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + MinimumAmount = "1.23", + PlanPhaseOrder = 0, + Price = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3485,43 +2642,33 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); + }, + PriceID = "h74gfhdjvn7ujokd", + StartDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice copied = new(model); + + Assert.Equal(model, copied); } +} +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTest : TestBase +{ [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() + public void NewSubscriptionUnitValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + new Subscriptions::NewSubscriptionUnitPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, 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", - }, + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3550,6 +2697,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3557,29 +2705,28 @@ public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() } [Fact] - public void NewSubscriptionCumulativeGroupedBulkValidationWorks() + public void NewSubscriptionTieredValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + new Subscriptions::NewSubscriptionTieredPrice() { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() { - DimensionValues = + Tiers = [ new() { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", + FirstUnit = 0, UnitAmount = "unit_amount", + LastUnit = 0, }, ], - Group = "group", + Prorated = true, }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3608,6 +2755,7 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3615,21 +2763,15 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() } [Fact] - public void CumulativeGroupedAllocationValidationWorks() + public void NewSubscriptionBulkValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() + new Subscriptions::NewSubscriptionBulkPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::ModelType.Bulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3659,6 +2801,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3666,15 +2809,23 @@ public void CumulativeGroupedAllocationValidationWorks() } [Fact] - public void MinimumValidationWorks() + public void BulkWithFiltersValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum() + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3704,6 +2855,7 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3711,21 +2863,16 @@ public void MinimumValidationWorks() } [Fact] - public void NewSubscriptionMinimumCompositeValidationWorks() + public void NewSubscriptionPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + new Subscriptions::NewSubscriptionPackagePrice() { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3754,6 +2901,7 @@ public void NewSubscriptionMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3761,16 +2909,24 @@ public void NewSubscriptionMinimumCompositeValidationWorks() } [Fact] - public void PercentValidationWorks() + public void NewSubscriptionMatrixValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent() + new Subscriptions::NewSubscriptionMatrixPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3799,6 +2955,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3806,21 +2963,25 @@ public void PercentValidationWorks() } [Fact] - public void EventOutputValidationWorks() + public void NewSubscriptionThresholdTotalAmountValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + 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() @@ -3849,6 +3010,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3856,16 +3018,24 @@ public void EventOutputValidationWorks() } [Fact] - public void NewSubscriptionUnitSerializationRoundtripWorks() + public void NewSubscriptionTieredPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitPrice() + new Subscriptions::NewSubscriptionTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, 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() @@ -3894,41 +3064,43 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionTieredSerializationRoundtripWorks() + public void NewSubscriptionTieredWithMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPrice() + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + ModelType = + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, Name = "Annual fee", - TieredConfig = new() + TieredWithMinimumConfig = new() { Tiers = [ new() { - FirstUnit = 0, + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", - LastUnit = 0, }, ], - Prorated = true, + HideZeroAmountTiers = true, + Prorate = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3958,29 +3130,31 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionBulkSerializationRoundtripWorks() + public void NewSubscriptionGroupedTieredValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionBulkPrice() + new Subscriptions::NewSubscriptionGroupedTieredPrice() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.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::ModelType.Bulk, + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4010,38 +3184,43 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void NewSubscriptionTieredPackageWithMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters() + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + PackageSize = 0, Tiers = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, ], }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4070,30 +3249,30 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionPackageSerializationRoundtripWorks() + public void NewSubscriptionPackageWithAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionPackagePrice() + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4122,38 +3301,25 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixSerializationRoundtripWorks() + public void NewSubscriptionUnitWithPercentValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixPrice() + new Subscriptions::NewSubscriptionUnitWithPercentPrice() { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, ItemID = "item_id", - MatrixConfig = new() - { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + ModelType = + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4182,39 +3348,34 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() + public void NewSubscriptionMatrixWithAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() + MatrixWithAllocationConfig = new() { - ConsumptionTable = + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, ], - Prorate = true, }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4243,38 +3404,26 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageSerializationRoundtripWorks() + public void TieredWithProrationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.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" }, - ], - }, + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4303,50 +3452,25 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() + public void NewSubscriptionUnitWithProrationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, 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, - }, + UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4375,37 +3499,29 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() + public void NewSubscriptionGroupedAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() { + Allocation = "allocation", GroupingKey = "x", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], + OverageUnitRate = "overage_unit_rate", }, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4435,49 +3551,30 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() + public void NewSubscriptionBulkWithProrationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + new Subscriptions::NewSubscriptionBulkWithProrationPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.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::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, 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() @@ -4506,36 +3603,31 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() + public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4564,31 +3656,44 @@ public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() + public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() + { + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = + [ + new() + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ], + }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4617,39 +3722,29 @@ public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() + public void GroupedWithMinMaxThresholdsValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4679,32 +3774,37 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void NewSubscriptionMatrixWithDisplayNameValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.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::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4733,31 +3833,34 @@ public void TieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() + public void NewSubscriptionGroupedTieredPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4786,35 +3889,33 @@ public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() + public void NewSubscriptionMaxGroupTieredPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() { - Allocation = "allocation", GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], }, - ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4844,36 +3945,42 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() + public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + 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", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4902,37 +4009,44 @@ public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() + public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() { Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + 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() @@ -4961,49 +4075,36 @@ public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void NewSubscriptionCumulativeGroupedBulkValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = + DimensionValues = [ new() { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, - ], + Group = "group", }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5033,33 +4134,27 @@ public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks( Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void CumulativeGroupedAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, ItemID = "item_id", Name = "Annual fee", @@ -5091,42 +4186,28 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() + public void NewSubscriptionMinimumCompositeValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + MinimumCompositeConfig = new() { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], + MinimumAmount = "minimum_amount", + Prorated = true, }, ModelType = - Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5156,40 +4237,24 @@ public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() + public void PercentValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent() { - 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::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5218,39 +4283,28 @@ public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() + public void EventOutputValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, - ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5280,47 +4334,24 @@ public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void NewSubscriptionUnitSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + new Subscriptions::NewSubscriptionUnitPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5349,6 +4380,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5363,35 +4395,27 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo } [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void NewSubscriptionTieredSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + new Subscriptions::NewSubscriptionTieredPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + TieredConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = + Tiers = [ new() { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, }, ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", + Prorated = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5421,6 +4445,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtrip Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5435,28 +4460,15 @@ public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtrip } [Fact] - public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() + public void NewSubscriptionBulkSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + new Subscriptions::NewSubscriptionBulkPrice() { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + ModelType = Subscriptions::ModelType.Bulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5486,6 +4498,7 @@ public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5500,20 +4513,22 @@ public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void BulkWithFiltersSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5544,6 +4559,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5558,16 +4574,16 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void NewSubscriptionPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum() + new Subscriptions::NewSubscriptionPackagePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5596,6 +4612,7 @@ public void MinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5610,20 +4627,23 @@ public void MinimumSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() + public void NewSubscriptionMatrixSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + new Subscriptions::NewSubscriptionMatrixPrice() { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() + MatrixConfig = new() { - MinimumAmount = "minimum_amount", - Prorated = true, + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5653,6 +4673,7 @@ public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5667,16 +4688,25 @@ public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() } [Fact] - public void PercentSerializationRoundtripWorks() + public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent() + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, Name = "Annual fee", - PercentConfig = new(0), + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5705,6 +4735,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5719,21 +4750,24 @@ public void PercentSerializationRoundtripWorks() } [Fact] - public void EventOutputSerializationRoundtripWorks() + public void NewSubscriptionTieredPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() + new Subscriptions::NewSubscriptionTieredPackagePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, Name = "Annual fee", + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5762,6 +4796,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5774,29 +4809,38 @@ public void EventOutputSerializationRoundtripWorks() Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, + Name = "Annual fee", + TieredWithMinimumConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() + { + 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, }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5825,105 +4869,38 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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 + ); - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = - new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedBulkWithFiltersConfig, model.BulkWithFiltersConfig); - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + GroupingKey = "x", Tiers = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -5953,39 +4930,50 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", 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 NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + PackageSize = 0, Tiers = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, ], }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6014,117 +5002,37 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = - new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedBulkWithFiltersConfig, deserialized.BulkWithFiltersConfig); - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6153,681 +5061,1121 @@ public void Validation_Works() Duration = 0, DurationUnit = 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 + ); - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", - }; - - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() + UnitWithPercentConfig = new() { Percent = "percent", 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters - { - BulkWithFiltersConfig = new() + Currency = "currency", + DimensionalPriceConfiguration = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTest - : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, model.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], model.Filters[i]); - } - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + 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 NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - 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::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, + }, + LicenseTypeID = "license_type_id", + 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 TieredWithProrationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + 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 + ); - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest - : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - PropertyKey = "x", - PropertyValue = "x", + 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, + }, + 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 + ); - 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 NewSubscriptionGroupedAllocationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - PropertyKey = "x", - PropertyValue = "x", + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + 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 NewSubscriptionBulkWithProrationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionBulkWithProrationPrice() { - PropertyKey = "x", - PropertyValue = "x", + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() { - PropertyKey = "x", - PropertyValue = "x", + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + 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 + ); - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTierTest - : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + 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, + }, + 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 + ); - 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + 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); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + 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 + ); - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() { - UnitAmount = "unit_amount", + 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, + }, + 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.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() { - UnitAmount = "unit_amount", + 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", + GroupingKey = "x", + 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, + }, + 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 + ); - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() { - UnitAmount = "unit_amount", - - TierLowerBound = null, + 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, + }, + 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.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - UnitAmount = "unit_amount", - - TierLowerBound = null, + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadenceTest : TestBase -{ - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Custom - )] - public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Custom - )] - public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > - >(json, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfigTest - : TestBase -{ [Fact] - public void UnitValidationWorks() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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, + }, + LicenseTypeID = "license_type_id", + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = - new SharedTieredConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice 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, + }, + LicenseTypeID = "license_type_id", + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6836,26 +6184,56 @@ public void UnitSerializationRoundtripWorks() } [Fact] - public void TieredSerializationRoundtripWorks() + public void EventOutputSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = - new SharedTieredConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6864,21 +6242,27 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -6907,20 +6291,29 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = + new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -6929,7 +6322,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6950,14 +6343,15 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -6969,6 +6363,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) @@ -6984,15 +6379,21 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7021,13 +6422,14 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7039,15 +6441,21 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7076,28 +6484,37 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = + new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -7106,7 +6523,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7127,14 +6544,15 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -7149,6 +6567,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) @@ -7164,15 +6583,21 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7201,6 +6626,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7212,15 +6638,21 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; Assert.Null(model.BillableMetricID); @@ -7245,6 +6677,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); @@ -7255,15 +6689,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -7273,15 +6713,21 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = null, BilledInAdvance = null, @@ -7294,6 +6740,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7320,6 +6767,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); @@ -7330,161 +6779,132 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadenceTest - : TestBase -{ - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom - )] - public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence - > value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom - )] - public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence - > value = rawValue; + 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", - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence - > - >(json, ModelBase.SerializerOptions); + BillableMetricID = null, + BilledInAdvance = null, + 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.Equal(value, deserialized); + model.Validate(); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void CopyConstructor_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence - > - >(json, ModelBase.SerializerOptions); + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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", + }; - Assert.Equal(value, deserialized); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters copied = + new(model); + + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; - List expectedTiers = + List expectedFilters = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ]; + Assert.Equal(expectedFilters.Count, model.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], model.Filters[i]); + } Assert.Equal(expectedTiers.Count, model.Tiers.Count); for (int i = 0; i < expectedTiers.Count; i++) { @@ -7496,14 +6916,19 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7515,24 +6940,39 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - List expectedTiers = + List expectedFilters = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { PropertyKey = "x", PropertyValue = "x" }, + ]; + List expectedTiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ]; + Assert.Equal(expectedFilters.Count, deserialized.Filters.Count); + for (int i = 0; i < expectedFilters.Count; i++) + { + Assert.Equal(expectedFilters[i], deserialized.Filters[i]); + } Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); for (int i = 0; i < expectedTiers.Count; i++) { @@ -7544,362 +6984,168 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; model.Validate(); } -} - -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTierTest - : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier - { - 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::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier - { - 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() + public void CopyConstructor_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; - - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - } - - [Fact] - public void Validation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig copied = + new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase { [Fact] - public void UnitValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = - new SharedTieredConversionRateConfig() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + PropertyKey = "x", + PropertyValue = "x", }; - value.Validate(); + + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, model.PropertyKey); + Assert.Equal(expectedPropertyValue, model.PropertyValue); } [Fact] - public void UnitSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = - new SharedUnitConversionRateConfig() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + PropertyKey = "x", + PropertyValue = "x", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( - element, + JsonSerializer.Deserialize( + json, ModelBase.SerializerOptions ); - Assert.Equal(value, deserialized); + Assert.Equal(model, deserialized); } [Fact] - public void TieredSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = - new SharedTieredConversionRateConfig() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + PropertyKey = "x", + PropertyValue = "x", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + 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); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsTest - : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - 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", + PropertyKey = "x", + PropertyValue = "x", }; - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + PropertyKey = "x", + PropertyValue = "x", }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig - ); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter copied = + new(model); - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(model, copied); } +} +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTierTest + : TestBase +{ [Fact] - public void SerializationRoundtrip_Works() + public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + string 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7911,189 +7157,35 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig - ); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; model.Validate(); @@ -8103,66 +7195,22 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", + UnitAmount = "unit_amount", }; - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_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", + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", }; model.Validate(); @@ -8172,130 +7220,77 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", + UnitAmount = "unit_amount", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + TierLowerBound = null, }; - 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.TierLowerBound); + Assert.True(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", + UnitAmount = "unit_amount", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + TierLowerBound = null, }; model.Validate(); } + + [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 SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadenceTest - : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence > value = rawValue; value.Validate(); } @@ -8306,7 +7301,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -8316,167 +7311,72 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence - > - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence > >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } -} - -public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest - : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; - - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } - - [Fact] - public void FieldRoundtripThroughSerialization_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; - - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); - } - - [Fact] - public void Validation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; - model.Validate(); + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8488,7 +7388,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8509,7 +7409,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8517,7 +7417,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8528,7 +7428,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8545,7 +7445,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8554,26 +7454,21 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationTest - : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8602,28 +7497,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = - new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8632,7 +7520,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8653,17 +7541,15 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -8675,6 +7561,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) @@ -8690,19 +7577,15 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8731,13 +7614,14 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8749,19 +7633,15 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8790,13 +7670,14 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8804,22 +7685,14 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = - new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -8828,7 +7701,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8849,17 +7722,15 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -8874,6 +7745,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) @@ -8889,19 +7761,15 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -8930,6 +7798,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8941,19 +7810,15 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; Assert.Null(model.BillableMetricID); @@ -8978,6 +7843,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); @@ -8988,19 +7855,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -9010,19 +7873,15 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -9035,6 +7894,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9061,6 +7921,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); @@ -9071,19 +7933,15 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = null, BilledInAdvance = null, @@ -9096,44 +7954,97 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadenceTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > value = rawValue; value.Validate(); } @@ -9144,7 +8055,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -9154,38 +8065,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > >(json, ModelBase.SerializerOptions); @@ -9198,14 +8109,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > >(json, ModelBase.SerializerOptions); @@ -9213,29 +8124,123 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [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 + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + string expectedTierLowerBound = "tier_lower_bound"; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); Assert.Equal(expectedUnitAmount, model.UnitAmount); } @@ -9243,17 +8248,15 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9265,30 +8268,24 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; + string expectedTierLowerBound = "tier_lower_bound"; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } @@ -9296,25 +8293,39 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", }; 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 SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9326,7 +8337,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -9347,7 +8358,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9355,7 +8366,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9366,7 +8377,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -9383,7 +8394,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9392,59 +8403,76 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string expectedItemID = "item_id"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -9454,7 +8482,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9475,12 +8503,16 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -9494,6 +8526,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) @@ -9508,48 +8541,56 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -9560,48 +8601,56 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9609,13 +8658,21 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; string expectedItemID = "item_id"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -9625,7 +8682,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9646,12 +8703,16 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -9668,6 +8729,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) @@ -9675,51 +8737,59 @@ public void FieldRoundtripThroughSerialization_Works() 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::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() + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + } + + [Fact] + public void Validation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; model.Validate(); } @@ -9727,14 +8797,21 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + }; Assert.Null(model.BillableMetricID); Assert.False(model.RawData.ContainsKey("billable_metric_id")); @@ -9758,6 +8835,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); @@ -9767,14 +8846,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + }; model.Validate(); } @@ -9782,28 +8868,36 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; Assert.Null(model.BillableMetricID); Assert.True(model.RawData.ContainsKey("billable_metric_id")); @@ -9827,6 +8921,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); @@ -9836,62 +8932,127 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadenceTest + : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > value = rawValue; value.Validate(); } @@ -9902,7 +9063,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -9912,38 +9073,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > >(json, ModelBase.SerializerOptions); @@ -9956,14 +9117,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > >(json, ModelBase.SerializerOptions); @@ -9971,38 +9132,47 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfigTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedMaximumCharge, model.MaximumCharge); + Assert.Equal(expectedMinimumCharge, model.MinimumCharge); + Assert.Equal(expectedPerUnitRate, model.PerUnitRate); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10014,104 +9184,74 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); + Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); + Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - MinimumAmount = "minimum_amount", + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void CopyConstructor_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = + new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10123,7 +9263,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -10144,7 +9284,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10152,7 +9292,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10163,7 +9303,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -10180,7 +9320,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10189,60 +9329,77 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig expectedPercentConfig = - new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10251,7 +9408,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10272,14 +9429,18 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -10291,6 +9452,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) @@ -10305,48 +9467,56 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10357,48 +9527,56 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10406,14 +9584,22 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig expectedPercentConfig = - new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10422,7 +9608,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10443,14 +9629,18 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -10465,6 +9655,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) @@ -10479,44 +9670,52 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; model.Validate(); } @@ -10524,14 +9723,21 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - }; + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + }; Assert.Null(model.BillableMetricID); Assert.False(model.RawData.ContainsKey("billable_metric_id")); @@ -10555,6 +9761,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); @@ -10564,14 +9772,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - }; + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + }; model.Validate(); } @@ -10579,28 +9794,36 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; Assert.Null(model.BillableMetricID); Assert.True(model.RawData.ContainsKey("billable_metric_id")); @@ -10624,6 +9847,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); @@ -10633,62 +9858,127 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, - }; + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadenceTest + : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > value = rawValue; value.Validate(); } @@ -10699,7 +9989,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -10709,38 +9999,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > >(json, ModelBase.SerializerOptions); @@ -10753,14 +10043,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > >(json, ModelBase.SerializerOptions); @@ -10768,34 +10058,47 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - Percent = 0, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; - double expectedPercent = 0; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedPercent, model.Percent); + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - Percent = 0, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10807,44 +10110,74 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - Percent = 0, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - double expectedPercent = 0; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(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::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; - Assert.Equal(expectedPercent, deserialized.Percent); + model.Validate(); } [Fact] - public void Validation_Works() + public void CopyConstructor_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - Percent = 0, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; - model.Validate(); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10856,7 +10189,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -10877,7 +10210,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10885,7 +10218,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10896,7 +10229,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -10913,7 +10246,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10922,23 +10255,18 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10967,25 +10295,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig expectedEventOutputConfig = - new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); string expectedName = "Annual fee"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig expectedPercentConfig = + new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10994,7 +10318,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -11015,14 +10339,15 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -11034,6 +10359,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) @@ -11048,18 +10374,13 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11088,13 +10409,14 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -11105,18 +10427,13 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11145,13 +10462,14 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -11159,19 +10477,14 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig expectedEventOutputConfig = - new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); string expectedName = "Annual fee"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig expectedPercentConfig = + new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -11180,7 +10493,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -11201,14 +10514,15 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -11223,6 +10537,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) @@ -11237,18 +10552,13 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11277,6 +10587,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11287,18 +10598,13 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -11323,6 +10629,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); @@ -11332,18 +10640,13 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), }; model.Validate(); @@ -11352,18 +10655,13 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -11376,6 +10674,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -11402,6 +10701,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); @@ -11411,18 +10712,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -11435,43 +10731,92 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent copied = new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > value = rawValue; value.Validate(); } @@ -11482,7 +10827,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -11492,38 +10837,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(json, ModelBase.SerializerOptions); @@ -11536,14 +10881,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(json, ModelBase.SerializerOptions); @@ -11551,43 +10896,34 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigTest - : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Percent = 0, }; - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + double expectedPercent = 0; - Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedPercent, model.Percent); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Percent = 0, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -11599,519 +10935,871 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Percent = 0, }; 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"; + double expectedPercent = 0; - Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedPercent, deserialized.Percent); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + Percent = 0, }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - UnitRatingKey = "x", + Percent = 0, }; - Assert.Null(model.DefaultUnitRate); - Assert.False(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.False(model.RawData.ContainsKey("grouping_key")); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig copied = + new(model); + + Assert.Equal(model, copied); } +} +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigTest + : TestBase +{ [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void UnitValidationWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + new SharedUnitConversionRateConfig() { - UnitRatingKey = "x", + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; + value.Validate(); + } - model.Validate(); + [Fact] + public void TieredValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void UnitSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + new SharedUnitConversionRateConfig() { - UnitRatingKey = "x", + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - DefaultUnitRate = null, - GroupingKey = null, + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig 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.Null(model.DefaultUnitRate); - Assert.True(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.True(model.RawData.ContainsKey("grouping_key")); + Assert.Equal(value, deserialized); } +} +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void FieldRoundtrip_Works() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; - DefaultUnitRate = null, - GroupingKey = null, + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > expectedCadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig expectedEventOutputConfig = + new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; + string expectedCurrency = "currency"; + NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; - model.Validate(); + 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); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigTest - : TestBase -{ [Fact] - public void UnitValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = - new SharedUnitConversionRateConfig() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = - new SharedTieredConversionRateConfig() + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } - - [Fact] - public void UnitSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = - new SharedUnitConversionRateConfig() + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( - element, + JsonSerializer.Deserialize( + json, ModelBase.SerializerOptions ); - Assert.Equal(value, deserialized); + Assert.Equal(model, deserialized); } [Fact] - public void TieredSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = - new SharedTieredConversionRateConfig() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - 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) - { - // 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 + 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() { - AdjustmentID = "h74gfhdjvn7ujokd", + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; - string expectedAdjustmentID = "h74gfhdjvn7ujokd"; + 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(expectedAdjustmentID, model.AdjustmentID); + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void SerializationRoundtrip_Works() + public void Validation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { - AdjustmentID = "h74gfhdjvn7ujokd", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + 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); + model.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { - AdjustmentID = "h74gfhdjvn7ujokd", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", }; - 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); + 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 Validation_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { - AdjustmentID = "h74gfhdjvn7ujokd", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", }; model.Validate(); } -} -public class SubscriptionSchedulePlanChangeParamsRemovePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", - string expectedExternalPriceID = "external_price_id"; - string expectedPriceID = "h74gfhdjvn7ujokd"; + BillableMetricID = null, + BilledInAdvance = null, + 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.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedPriceID, model.PriceID); + 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 SerializationRoundtrip_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", - }; + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + BillableMetricID = null, + BilledInAdvance = null, + 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.Equal(model, deserialized); + model.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void CopyConstructor_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + 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", - PriceID = "h74gfhdjvn7ujokd", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = 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 expectedExternalPriceID = "external_price_id"; - string expectedPriceID = "h74gfhdjvn7ujokd"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput copied = new( + model + ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedPriceID, deserialized.PriceID); + Assert.Equal(model, copied); } +} - [Fact] - public void Validation_Works() +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceTest : TestBase +{ + [Theory] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom + )] + public void Validation_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue + ) { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", - }; - - model.Validate(); + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > value = rawValue; + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void InvalidEnumValidationThrows_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.PriceID); - Assert.False(model.RawData.ContainsKey("price_id")); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + [Theory] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime + )] + [InlineData( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom + )] + public void SerializationRoundtrip_Works( + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue + ) { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; - - model.Validate(); - } + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > value = rawValue; - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = null, - PriceID = null, - }; + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > + >(json, ModelBase.SerializerOptions); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.PriceID); - Assert.True(model.RawData.ContainsKey("price_id")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = null, - PriceID = null, - }; + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > + >(json, ModelBase.SerializerOptions); - model.Validate(); + Assert.Equal(value, deserialized); } } -public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment - { - Adjustment = new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", - }; - - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment expectedAdjustment = - new NewPercentageDiscount() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; + + Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, model.GroupingKey); } [Fact] public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment - { - Adjustment = new NewPercentageDiscount() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", - }; + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -12122,263 +11810,171 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment - { - Adjustment = new NewPercentageDiscount() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", - }; + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment expectedAdjustment = - new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); + Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); } [Fact] public void Validation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment - { - Adjustment = new NewPercentageDiscount() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - ReplacesAdjustmentID = "replaces_adjustment_id", - }; + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; model.Validate(); } -} -public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentTest : TestBase -{ [Fact] - public void NewPercentageDiscountValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewPercentageDiscount() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + UnitRatingKey = "x", }; - value.Validate(); + + Assert.Null(model.DefaultUnitRate); + Assert.False(model.RawData.ContainsKey("default_unit_rate")); + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); } [Fact] - public void NewUsageDiscountValidationWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewUsageDiscount() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - 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, + UnitRatingKey = "x", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewAmountDiscountValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewAmountDiscount() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.Usage, + UnitRatingKey = "x", + + 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 NewMinimumValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewMinimum() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - AdjustmentType = NewMinimumAdjustmentType.Minimum, - ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.Usage, + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, + }; + + 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 + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; value.Validate(); } [Fact] - public void NewMaximumValidationWorks() + public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewMaximum() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = + new SharedTieredConversionRateConfig() { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.Usage, + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), }; value.Validate(); } [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = + new SharedUnitConversionRateConfig() { - 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, + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -12387,411 +11983,199 @@ public void NewPercentageDiscountSerializationRoundtripWorks() } [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewUsageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = + new SharedTieredConversionRateConfig() { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.Equal(value, deserialized); } +} + +public class BillingCycleAlignmentTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::BillingCycleAlignment.Unchanged)] + [InlineData(Subscriptions::BillingCycleAlignment.PlanChangeDate)] + [InlineData(Subscriptions::BillingCycleAlignment.StartOfMonth)] + public void Validation_Works(Subscriptions::BillingCycleAlignment rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() + public void InvalidEnumValidationThrows_Works() { - 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 value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Subscriptions::BillingCycleAlignment.Unchanged)] + [InlineData(Subscriptions::BillingCycleAlignment.PlanChangeDate)] + [InlineData(Subscriptions::BillingCycleAlignment.StartOfMonth)] + public void SerializationRoundtrip_Works(Subscriptions::BillingCycleAlignment rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class SubscriptionSchedulePlanChangeParamsRemoveAdjustmentTest : TestBase +{ + [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 + { + AdjustmentID = "h74gfhdjvn7ujokd", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( - element, + JsonSerializer.Deserialize( + json, ModelBase.SerializerOptions ); - Assert.Equal(value, deserialized); + Assert.Equal(model, deserialized); } [Fact] - public void NewMinimumSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - 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 model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment + { + AdjustmentID = "h74gfhdjvn7ujokd", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); + + string expectedAdjustmentID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); + } - Assert.Equal(value, deserialized); + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment + { + AdjustmentID = "h74gfhdjvn7ujokd", + }; + + model.Validate(); } [Fact] - public void NewMaximumSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewMaximum() - { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment + { + AdjustmentID = "h74gfhdjvn7ujokd", + }; - Assert.Equal(value, deserialized); + Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment copied = new(model); + + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsReplacePriceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsRemovePriceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, PriceID = "h74gfhdjvn7ujokd", }; - 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, - }, - ], + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedPriceID, model.PriceID); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + { 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( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -12802,271 +12186,33 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ], ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, PriceID = "h74gfhdjvn7ujokd", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedReplacesPriceID = "replaces_price_id"; - NewAllocationPrice expectedAllocationPrice = new() - { - 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, - }, - ], + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + { ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - Price = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }, PriceID = "h74gfhdjvn7ujokd", }; @@ -13076,25 +12222,10 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice - { - ReplacesPriceID = "replaces_price_id", - }; + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; - Assert.Null(model.AllocationPrice); - Assert.False(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.False(model.RawData.ContainsKey("discounts")); Assert.Null(model.ExternalPriceID); Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.MaximumAmount); - Assert.False(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.False(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.Price); - Assert.False(model.RawData.ContainsKey("price")); Assert.Null(model.PriceID); Assert.False(model.RawData.ContainsKey("price_id")); } @@ -13102,10 +12233,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice - { - ReplacesPriceID = "replaces_price_id", - }; + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; model.Validate(); } @@ -13113,34 +12241,14 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - ReplacesPriceID = "replaces_price_id", - - AllocationPrice = null, - Discounts = null, ExternalPriceID = null, - FixedPriceQuantity = null, - MaximumAmount = null, - MinimumAmount = null, - Price = null, PriceID = null, }; - Assert.Null(model.AllocationPrice); - Assert.True(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.True(model.RawData.ContainsKey("discounts")); Assert.Null(model.ExternalPriceID); Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.MaximumAmount); - Assert.True(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.True(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.Price); - Assert.True(model.RawData.ContainsKey("price")); Assert.Null(model.PriceID); Assert.True(model.RawData.ContainsKey("price_id")); } @@ -13148,875 +12256,620 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - ReplacesPriceID = "replaces_price_id", - - AllocationPrice = null, - Discounts = null, ExternalPriceID = null, - FixedPriceQuantity = null, - MaximumAmount = null, - MinimumAmount = null, - Price = null, PriceID = null, }; model.Validate(); } -} -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTest : TestBase -{ [Fact] - public void NewSubscriptionUnitValidationWorks() + public void CopyConstructor_Works() { - 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(); + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice copied = new(model); + + Assert.Equal(model, copied); } +} +public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentTest : TestBase +{ [Fact] - public void NewSubscriptionTieredValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() - { - Tiers = - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ], - Prorated = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; - [Fact] - public void NewSubscriptionBulkValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment expectedAdjustment = + new NewPercentageDiscount() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; - value.Validate(); + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); } [Fact] - public void BulkWithFiltersValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewSubscriptionPackageValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionPackagePrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, - Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + 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, }; - value.Validate(); + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); } [Fact] - public void NewSubscriptionMatrixValidationWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, - ItemID = "item_id", - MatrixConfig = new() - { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + 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", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment copied = new(model); + + Assert.Equal(model, copied); } +} +public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentTest : TestBase +{ [Fact] - public void NewSubscriptionThresholdTotalAmountValidationWorks() + public void NewPercentageDiscountValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() - { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageValidationWorks() + public void NewUsageDiscountValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewUsageDiscount() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewUsageDiscountPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionTieredWithMinimumValidationWorks() + public void NewAmountDiscountValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewAmountDiscount() { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() - { - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - HideZeroAmountTiers = true, - Prorate = true, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredValidationWorks() + public void NewMinimumValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMinimum() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() - { - GroupingKey = "x", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, + AdjustmentType = NewMinimumAdjustmentType.Minimum, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageWithMinimumValidationWorks() + public void NewMaximumValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMaximum() { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() - { - PackageSize = 0, - Tiers = - [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, }; value.Validate(); } [Fact] - public void NewSubscriptionPackageWithAllocationValidationWorks() + public void NewPercentageDiscountSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewPercentageDiscount() { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionUnitWithPercentValidationWorks() + public void NewUsageDiscountSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewUsageDiscount() { - 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", + 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(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionMatrixWithAllocationValidationWorks() + public void NewAmountDiscountSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewAmountDiscount() { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() - { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void TieredWithProrationValidationWorks() + public void NewMinimumSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMinimum() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + AdjustmentType = NewMinimumAdjustmentType.Minimum, ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionUnitWithProrationValidationWorks() + public void NewMaximumSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMaximum() { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, - Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Filters = + [ + new() + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } +} +public class SubscriptionSchedulePlanChangeParamsReplacePriceTest : TestBase +{ [Fact] - public void NewSubscriptionGroupedAllocationValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = 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", + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, + ], + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 2, + MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() + { + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14045,29 +12898,64 @@ public void NewSubscriptionGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); - } + }, + PriceID = "h74gfhdjvn7ujokd", + }; - [Fact] - public void NewSubscriptionBulkWithProrationValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + string expectedReplacesPriceID = "replaces_price_id"; + NewAllocationPrice expectedAllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_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"; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + 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() @@ -14096,30 +12984,91 @@ public void NewSubscriptionBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", 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.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); } [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() + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + LicenseTypeID = "license_type_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", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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() @@ -14148,43 +13097,78 @@ public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", 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 NewSubscriptionGroupedWithMeteredMinimumValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = 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" }, - ], + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_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", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() + { + 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() @@ -14213,29 +13197,72 @@ public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); - } + }, + PriceID = "h74gfhdjvn7ujokd", + }; - [Fact] - public void GroupedWithMinMaxThresholdsValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() + 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], }, + ], + ItemID = "item_id", + LicenseTypeID = "license_type_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"; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }; + 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() @@ -14264,36 +13291,96 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", 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.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); } [Fact] - public void NewSubscriptionMatrixWithDisplayNameValidationWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + LicenseTypeID = "license_type_id", + PerUnitCostBasis = "per_unit_cost_basis", + }, + Discounts = + [ + new() { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + ], + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 2, + MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + 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() @@ -14322,88 +13409,169 @@ public void NewSubscriptionMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); + }, + 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.MetricParameterOverrides); + Assert.False(model.RawData.ContainsKey("metric_parameter_overrides")); + 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, + MetricParameterOverrides = 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.MetricParameterOverrides); + Assert.True(model.RawData.ContainsKey("metric_parameter_overrides")); + 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, + MetricParameterOverrides = null, + MinimumAmount = null, + Price = null, + PriceID = null, + }; + + model.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredPackageValidationWorks() + public void CopyConstructor_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - 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() + 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", + LicenseTypeID = "license_type_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 NewSubscriptionMaxGroupTieredPackageValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + ], + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 2, + MaximumAmount = "1.23", + MetricParameterOverrides = new Dictionary() { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, + MinimumAmount = "1.23", + Price = new Subscriptions::NewSubscriptionUnitPrice() + { + 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() @@ -14432,40 +13600,32 @@ public void NewSubscriptionMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }; - value.Validate(); + }, + PriceID = "h74gfhdjvn7ujokd", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice copied = new(model); + + Assert.Equal(model, copied); } +} +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTest : TestBase +{ [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() + public void NewSubscriptionUnitValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + new Subscriptions::NewSubscriptionUnitPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14494,6 +13654,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14501,94 +13662,28 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() } [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() + public void NewSubscriptionTieredValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + new Subscriptions::NewSubscriptionTieredPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + TieredConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionCumulativeGroupedBulkValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() - { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = [ new() { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", + FirstUnit = 0, UnitAmount = "unit_amount", + LastUnit = 0, }, ], - Group = "group", + Prorated = true, }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14617,6 +13712,7 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14624,21 +13720,15 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() } [Fact] - public void CumulativeGroupedAllocationValidationWorks() + public void NewSubscriptionBulkValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() + new Subscriptions::NewSubscriptionBulkPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::ModelType.Bulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14668,6 +13758,7 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14675,15 +13766,23 @@ public void CumulativeGroupedAllocationValidationWorks() } [Fact] - public void MinimumValidationWorks() + public void BulkWithFiltersValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum() + 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14713,6 +13812,7 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14720,21 +13820,16 @@ public void MinimumValidationWorks() } [Fact] - public void NewSubscriptionMinimumCompositeValidationWorks() + public void NewSubscriptionPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + new Subscriptions::NewSubscriptionPackagePrice() { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14763,6 +13858,7 @@ public void NewSubscriptionMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14770,16 +13866,24 @@ public void NewSubscriptionMinimumCompositeValidationWorks() } [Fact] - public void PercentValidationWorks() + public void NewSubscriptionMatrixValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent() + new Subscriptions::NewSubscriptionMatrixPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14808,6 +13912,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14815,21 +13920,25 @@ public void PercentValidationWorks() } [Fact] - public void EventOutputValidationWorks() + public void NewSubscriptionThresholdTotalAmountValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput() + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + 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() @@ -14858,6 +13967,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14865,16 +13975,24 @@ public void EventOutputValidationWorks() } [Fact] - public void NewSubscriptionUnitSerializationRoundtripWorks() + public void NewSubscriptionTieredPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitPrice() + new Subscriptions::NewSubscriptionTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, 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() @@ -14903,41 +14021,43 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionTieredSerializationRoundtripWorks() + public void NewSubscriptionTieredWithMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPrice() + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + ModelType = + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, Name = "Annual fee", - TieredConfig = new() + TieredWithMinimumConfig = new() { Tiers = [ new() { - FirstUnit = 0, + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", - LastUnit = 0, }, ], - Prorated = true, + HideZeroAmountTiers = true, + Prorate = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14967,29 +14087,31 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionBulkSerializationRoundtripWorks() + public void NewSubscriptionGroupedTieredValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkPrice() + new Subscriptions::NewSubscriptionGroupedTieredPrice() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.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::ModelType.Bulk, + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15019,38 +14141,43 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void NewSubscriptionTieredPackageWithMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() + 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() @@ -15079,30 +14206,30 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionPackageSerializationRoundtripWorks() + public void NewSubscriptionPackageWithAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionPackagePrice() + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, + ModelType = + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15131,38 +14258,25 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixSerializationRoundtripWorks() + public void NewSubscriptionUnitWithPercentValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixPrice() + new Subscriptions::NewSubscriptionUnitWithPercentPrice() { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, ItemID = "item_id", - MatrixConfig = new() - { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + ModelType = + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15191,39 +14305,34 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() + public void NewSubscriptionMatrixWithAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() + MatrixWithAllocationConfig = new() { - ConsumptionTable = + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, ], - Prorate = true, }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15252,38 +14361,26 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageSerializationRoundtripWorks() + public void TieredWithProrationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.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" }, - ], - }, + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15312,50 +14409,25 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() + public void NewSubscriptionUnitWithProrationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, 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, - }, + UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15384,37 +14456,29 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() + public void NewSubscriptionGroupedAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() { + Allocation = "allocation", GroupingKey = "x", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], + OverageUnitRate = "overage_unit_rate", }, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15444,49 +14508,30 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() + public void NewSubscriptionBulkWithProrationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + new Subscriptions::NewSubscriptionBulkWithProrationPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.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::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, 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() @@ -15515,36 +14560,31 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() + public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15573,31 +14613,44 @@ public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() + public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() + { + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = + [ + new() + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ], + }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15626,39 +14679,29 @@ public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() + public void GroupedWithMinMaxThresholdsValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15688,32 +14731,37 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void NewSubscriptionMatrixWithDisplayNameValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.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::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15742,31 +14790,34 @@ public void TieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() + public void NewSubscriptionGroupedTieredPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15795,35 +14846,33 @@ public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() + public void NewSubscriptionMaxGroupTieredPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() { - Allocation = "allocation", GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], }, - ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15853,36 +14902,42 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() + public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + 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", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15911,37 +14966,44 @@ public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() + public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() { Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + 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() @@ -15970,49 +15032,36 @@ public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void NewSubscriptionCumulativeGroupedBulkValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = + DimensionValues = [ new() { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, - ], + Group = "group", }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -16042,33 +15091,27 @@ public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks( Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void CumulativeGroupedAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + UnitAmount = "unit_amount", }, ItemID = "item_id", Name = "Annual fee", @@ -16100,42 +15143,28 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() + public void NewSubscriptionMinimumCompositeValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + MinimumCompositeConfig = new() { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], + MinimumAmount = "minimum_amount", + Prorated = true, }, ModelType = - Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -16165,40 +15194,24 @@ public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() 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); + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() + public void PercentValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent() { - 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::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16227,39 +15240,28 @@ public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() + public void EventOutputValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput() { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, - ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = new() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -16289,47 +15291,24 @@ public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = 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); + value.Validate(); } [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void NewSubscriptionUnitSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + new Subscriptions::NewSubscriptionUnitPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16358,6 +15337,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16372,35 +15352,27 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo } [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void NewSubscriptionTieredSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + new Subscriptions::NewSubscriptionTieredPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + TieredConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = + Tiers = [ new() { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, }, ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", + Prorated = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -16430,6 +15402,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtrip Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16444,28 +15417,15 @@ public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtrip } [Fact] - public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() + public void NewSubscriptionBulkSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + new Subscriptions::NewSubscriptionBulkPrice() { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + ModelType = Subscriptions::ModelType.Bulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -16495,6 +15455,7 @@ public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16509,20 +15470,22 @@ public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void BulkWithFiltersSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + BulkWithFiltersConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], }, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -16553,6 +15516,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16567,16 +15531,16 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void NewSubscriptionPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum() + new Subscriptions::NewSubscriptionPackagePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16605,6 +15569,7 @@ public void MinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16619,20 +15584,23 @@ public void MinimumSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() + public void NewSubscriptionMatrixSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + new Subscriptions::NewSubscriptionMatrixPrice() { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() + MatrixConfig = new() { - MinimumAmount = "minimum_amount", - Prorated = true, + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -16662,6 +15630,7 @@ public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16676,16 +15645,25 @@ public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() } [Fact] - public void PercentSerializationRoundtripWorks() + public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent() + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadence.Annual, + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, Name = "Annual fee", - PercentConfig = new(0), + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16714,6 +15692,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16728,21 +15707,24 @@ public void PercentSerializationRoundtripWorks() } [Fact] - public void EventOutputSerializationRoundtripWorks() + public void NewSubscriptionTieredPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput() + new Subscriptions::NewSubscriptionTieredPackagePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, Name = "Annual fee", + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16771,6 +15753,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16783,29 +15766,38 @@ public void EventOutputSerializationRoundtripWorks() Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, + Name = "Annual fee", + TieredWithMinimumConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() + { + 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, }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16834,105 +15826,38 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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 + ); - 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 NewSubscriptionGroupedTieredSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + GroupingKey = "x", Tiers = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -16962,39 +15887,50 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", 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 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() @@ -17023,117 +15959,37 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", 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); - } - [Fact] - public void Validation_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, + Assert.Equal(value, deserialized); + } + + [Fact] + public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() + { + 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() @@ -17162,682 +16018,1121 @@ public void Validation_Works() Duration = 0, DurationUnit = 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 + ); - 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")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_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", - }; - - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_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", - - 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() + UnitWithPercentConfig = new() { Percent = "percent", 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" }, - ], - }, - 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" }, - ], + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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", }; - - 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 NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - 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::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, + }, + LicenseTypeID = "license_type_id", + 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 TieredWithProrationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() { - 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, + 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, + }, + 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 + ); - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest - : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - PropertyKey = "x", - PropertyValue = "x", + 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, + }, + 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 + ); - 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 NewSubscriptionGroupedAllocationSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - PropertyKey = "x", - PropertyValue = "x", + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + 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 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void 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, + }, + 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 + ); - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest - : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + 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, + }, + 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 + ); - 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, + }, + LicenseTypeID = "license_type_id", + 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, + }, + LicenseTypeID = "license_type_id", + 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); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + 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 + ); - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() { - UnitAmount = "unit_amount", + 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, + }, + 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.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() { - UnitAmount = "unit_amount", + 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", + GroupingKey = "x", + 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, + }, + 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 + ); - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() { - UnitAmount = "unit_amount", - - TierLowerBound = null, + 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, + }, + 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.Null(model.TierLowerBound); - Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - 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); + 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, + }, + 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 InvalidEnumSerializationRoundtrip_Works() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - 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::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, + }, + 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigTest - : TestBase -{ [Fact] - public void UnitValidationWorks() + public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + ItemID = "item_id", + MinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }, + ModelType = + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - value.Validate(); - } + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - [Fact] - public void TieredValidationWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = - new SharedTieredConversionRateConfig() - { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void UnitSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { - Subscriptions::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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17846,26 +17141,56 @@ 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17874,21 +17199,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() @@ -17917,20 +17248,29 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = + new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -17939,7 +17279,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17960,14 +17300,15 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -17979,6 +17320,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) @@ -17994,15 +17336,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() @@ -18031,13 +17379,14 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18049,15 +17398,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() @@ -18086,28 +17441,37 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = + new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); string expectedName = "Annual fee"; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = - new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -18116,7 +17480,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18137,14 +17501,15 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -18159,6 +17524,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) @@ -18174,15 +17540,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() @@ -18211,6 +17583,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18222,15 +17595,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); @@ -18255,6 +17634,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); @@ -18265,15 +17646,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), }; model.Validate(); @@ -18283,15 +17670,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, @@ -18304,6 +17697,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18330,6 +17724,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); @@ -18337,183 +17733,281 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void OptionalNullablePropertiesSetToNullValidation_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 = null, + BilledInAdvance = null, + 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 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.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(); + 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]); + } } -} -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceTest - : 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 SerializationRoundtrip_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" }, + ], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void InvalidEnumValidationThrows_Works() + public void FieldRoundtripThroughSerialization_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 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]); + } } - [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 Validation_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence - > value = rawValue; - - 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(); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void CopyConstructor_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); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig copied = + new(model); + + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + PropertyKey = "x", + PropertyValue = "x", }; - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + Assert.Equal(expectedPropertyKey, model.PropertyKey); + Assert.Equal(expectedPropertyValue, model.PropertyValue); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + PropertyKey = "x", + PropertyValue = "x", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18525,77 +18019,90 @@ 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(); } + + [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 SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTierTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - string expectedTierLowerBound = "tier_lower_bound"; string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18607,48 +18114,227 @@ 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 expectedTierLowerBound = "tier_lower_bound"; - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + 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(); } + + [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 SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigTest +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(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + 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); + + Assert.Equal(value, deserialized); + } +} + +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18660,7 +18346,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18681,7 +18367,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18689,7 +18375,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18700,7 +18386,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18717,7 +18403,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18726,26 +18412,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() @@ -18774,28 +18455,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -18804,7 +18478,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18825,17 +18499,15 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -18847,6 +18519,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) @@ -18862,19 +18535,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() @@ -18903,13 +18572,14 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -18921,19 +18591,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() @@ -18962,13 +18628,14 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18976,22 +18643,14 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = - new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); string expectedName = "Annual fee"; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig expectedTieredWithProrationConfig = + new([new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }]); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -19000,7 +18659,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19021,17 +18680,15 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -19046,6 +18703,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) @@ -19061,19 +18719,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() @@ -19102,6 +18756,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19113,19 +18768,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); @@ -19150,6 +18801,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); @@ -19160,19 +18813,15 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), }; model.Validate(); @@ -19182,19 +18831,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, @@ -19207,6 +18852,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19233,6 +18879,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); @@ -19243,19 +18891,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, @@ -19268,44 +18912,97 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > value = rawValue; value.Validate(); } @@ -19316,7 +19013,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -19326,38 +19023,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > >(json, ModelBase.SerializerOptions); @@ -19370,14 +19067,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > >(json, ModelBase.SerializerOptions); @@ -19385,47 +19082,42 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -19437,56 +19129,161 @@ 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(); } + + [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 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(); + } + + [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 : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19498,7 +19295,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19519,7 +19316,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19527,7 +19324,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19538,7 +19335,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19555,7 +19352,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19564,23 +19361,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", @@ -19612,26 +19409,27 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -19642,7 +19440,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19663,13 +19461,14 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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 + expectedGroupedWithMinMaxThresholdsConfig, + model.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); @@ -19685,6 +19484,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) @@ -19700,16 +19500,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", @@ -19741,13 +19541,14 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -19759,16 +19560,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", @@ -19800,13 +19601,14 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19814,20 +19616,20 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string expectedItemID = "item_id"; JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" + "grouped_with_min_max_thresholds" ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; @@ -19838,7 +19640,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19859,13 +19661,14 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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 + expectedGroupedWithMinMaxThresholdsConfig, + deserialized.GroupedWithMinMaxThresholdsConfig ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); @@ -19884,6 +19687,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) @@ -19899,16 +19703,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", @@ -19940,6 +19744,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19951,16 +19756,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", @@ -19988,6 +19793,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); @@ -19998,16 +19805,16 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -20020,16 +19827,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", @@ -20045,6 +19852,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20071,6 +19879,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); @@ -20081,16 +19891,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", @@ -20106,44 +19916,101 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_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 = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_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", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > value = rawValue; value.Validate(); } @@ -20154,7 +20021,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -20164,38 +20031,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >(json, ModelBase.SerializerOptions); @@ -20208,14 +20075,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >(json, ModelBase.SerializerOptions); @@ -20223,47 +20090,47 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; string expectedGroupingKey = "x"; - string expectedUnitAmount = "unit_amount"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedMaximumCharge, model.MaximumCharge); + Assert.Equal(expectedMinimumCharge, model.MinimumCharge); + Assert.Equal(expectedPerUnitRate, model.PerUnitRate); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -20275,56 +20142,74 @@ 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(); } + + [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 SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20336,7 +20221,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20357,7 +20242,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20365,7 +20250,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20376,7 +20261,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20393,7 +20278,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20402,59 +20287,76 @@ 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -20464,7 +20366,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20485,12 +20387,16 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = 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(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); @@ -20504,6 +20410,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) @@ -20518,48 +20425,56 @@ 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -20570,48 +20485,56 @@ 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20619,13 +20542,21 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -20635,7 +20566,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20656,12 +20587,16 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = 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(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); @@ -20678,6 +20613,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) @@ -20692,44 +20628,52 @@ 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; model.Validate(); } @@ -20737,14 +20681,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")); @@ -20768,6 +20719,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); @@ -20777,14 +20730,21 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - }; + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + }; model.Validate(); } @@ -20792,28 +20752,36 @@ 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; Assert.Null(model.BillableMetricID); Assert.True(model.RawData.ContainsKey("billable_metric_id")); @@ -20837,6 +20805,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); @@ -20846,62 +20816,127 @@ 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, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_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, - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation copied = + new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceTest + : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > value = rawValue; value.Validate(); } @@ -20912,7 +20947,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -20922,38 +20957,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > >(json, ModelBase.SerializerOptions); @@ -20966,14 +21001,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > >(json, ModelBase.SerializerOptions); @@ -20981,39 +21016,47 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -21025,104 +21068,74 @@ 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 + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - MinimumAmount = "minimum_amount", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void CopyConstructor_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", }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -21134,7 +21147,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -21155,7 +21168,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -21163,7 +21176,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -21174,7 +21187,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -21191,7 +21204,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -21240,6 +21253,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21283,6 +21297,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -21302,6 +21317,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) @@ -21351,6 +21367,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21403,6 +21420,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21454,6 +21472,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -21476,6 +21495,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) @@ -21525,6 +21545,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21566,6 +21587,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); @@ -21609,6 +21632,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -21635,6 +21659,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); @@ -21663,12 +21689,63 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent copied = new( + model + ); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadenceTest : TestBase @@ -21848,6 +21925,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 @@ -21980,6 +22072,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -22028,6 +22121,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -22047,6 +22141,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) @@ -22102,6 +22197,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -22160,6 +22256,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -22216,6 +22313,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -22238,6 +22336,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) @@ -22293,6 +22392,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -22340,6 +22440,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); @@ -22395,6 +22497,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -22421,6 +22524,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); @@ -22455,12 +22560,68 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; 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, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput copied = + new(model); + + Assert.Equal(model, copied); + } } public class SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputCadenceTest : TestBase @@ -22716,6 +22877,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..ecbc9e207 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,9 +650,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -1059,6 +1077,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1126,6 +1145,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 +1237,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1279,9 +1305,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -1718,6 +1754,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1785,6 +1822,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 +1916,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1940,9 +1984,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -2377,6 +2431,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2444,6 +2499,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 +2593,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2599,9 +2661,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -3023,6 +3095,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3090,6 +3163,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 +3255,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3243,9 +3323,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -3682,6 +3772,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3749,6 +3840,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 +3934,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3904,9 +4002,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -3925,4 +4033,677 @@ 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"], + }, + ], + 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", + }, + }, + ], + 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"], + }, + ], + 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") }, + }, + }, + ], + 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..84a564135 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,9 +632,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -1030,6 +1048,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1097,6 +1116,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 +1199,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1241,9 +1267,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ]; CouponRedemption expectedRedeemedCoupon = new() @@ -1714,6 +1750,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1781,6 +1818,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 +1908,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1932,9 +1976,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -2351,6 +2405,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2418,6 +2473,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 +2563,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2569,9 +2631,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -2982,6 +3054,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3049,6 +3122,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 +3205,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3193,9 +3273,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ]; CouponRedemption expectedRedeemedCoupon = new() @@ -3675,6 +3765,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3742,6 +3833,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 +3923,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3893,9 +3991,19 @@ 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"], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, }, ], RedeemedCoupon = new() @@ -3911,6 +4019,657 @@ 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"], + }, + ], + 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", + }, + }, + ], + 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"], + }, + ], + 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") }, + }, + }, + ], + 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/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.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.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.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/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.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.Tests/Services/PlanServiceTest.cs b/src/Orb.Tests/Services/PlanServiceTest.cs index 8df29ba72..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; @@ -39,8 +40,58 @@ public async Task Create_Works() }, ], ItemID = "item_id", + 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() { @@ -79,6 +130,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/Core/ApiEnum.cs b/src/Orb/Core/ApiEnum.cs index 32b85f268..9a5aac55c 100644 --- a/src/Orb/Core/ApiEnum.cs +++ b/src/Orb/Core/ApiEnum.cs @@ -94,6 +94,12 @@ public virtual bool Equals(ApiEnum? other) return other != null && JsonElement.DeepEquals(this.Json, other.Json); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + public override int GetHashCode() { return 0; 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/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/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..36369c9ab 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 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( @@ -95,7 +109,7 @@ public void Dispose() } } -public sealed class HttpResponse : global::Orb.Core.HttpResponse +public sealed class HttpResponse : HttpResponse { readonly Func> _deserialize; @@ -106,7 +120,7 @@ internal HttpResponse(Func> deserialize) [SetsRequiredMembers] internal HttpResponse( - global::Orb.Core.HttpResponse response, + HttpResponse response, Func> deserialize ) : this(deserialize) @@ -125,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; @@ -138,7 +152,7 @@ internal StreamingHttpResponse( [SetsRequiredMembers] internal StreamingHttpResponse( - global::Orb.Core.HttpResponse response, + HttpResponse response, Func> enumerate ) : this(enumerate) 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/ModelBase.cs b/src/Orb/Core/ModelBase.cs index 165003cf9..01d4c5d82 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; @@ -398,11 +399,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(), @@ -432,12 +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(), + 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< @@ -448,16 +580,169 @@ 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(), + 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, @@ -471,7 +756,6 @@ protected ModelBase(ModelBase modelBase) string, ExternalPlanID::ReplacePricePriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -569,6 +853,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 @@ -588,7 +886,6 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -596,12 +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(), new ApiEnumConverter(), @@ -620,13 +947,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 +966,6 @@ protected ModelBase(ModelBase modelBase) string, Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter< - string, - Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence - >(), new ApiEnumConverter< string, Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadence @@ -825,7 +1146,6 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -842,7 +1162,6 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -859,7 +1178,6 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::PriceModelCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -883,10 +1201,6 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence - >(), new ApiEnumConverter< string, Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence @@ -912,10 +1226,6 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence - >(), new ApiEnumConverter< string, Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadence @@ -954,6 +1264,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/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 e676ca7c4..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"); + } + } } /// @@ -139,7 +253,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 +302,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); diff --git a/src/Orb/Core/ParamsBase.cs b/src/Orb/Core/ParamsBase.cs index e82921642..e66b4a4b4 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) { @@ -203,6 +203,13 @@ protected static void AddDefaultHeaders(HttpRequestMessage request, ClientOption 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; 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/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..2f72e278c 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) { @@ -492,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() { @@ -503,7 +506,23 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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/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..4822a34c1 100644 --- a/src/Orb/Models/Alerts/Alert.cs +++ b/src/Orb/Models/Alerts/Alert.cs @@ -176,6 +176,39 @@ public IReadOnlyList? BalanceAlertStatus } } + /// + /// The property keys to group cost alerts by. Only present for cost alerts with + /// grouping enabled. + /// + public IReadOnlyList? GroupingKeys + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("grouping_keys"); + } + init + { + this._rawData.Set?>( + "grouping_keys", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// 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,12 +229,17 @@ public override void Validate() { item.Validate(); } + _ = this.GroupingKeys; + this.LicenseType?.Validate(); } public Alert() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Alert(Alert alert) : base(alert) { } +#pragma warning restore CS8618 public Alert(IReadOnlyDictionary rawData) { @@ -254,8 +292,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 +394,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) { @@ -394,6 +438,7 @@ public enum AlertType CreditBalanceRecovered, UsageExceeded, CostExceeded, + LicenseBalanceThresholdReached, } sealed class AlertTypeConverter : JsonConverter @@ -411,6 +456,7 @@ JsonSerializerOptions options "credit_balance_recovered" => AlertType.CreditBalanceRecovered, "usage_exceeded" => AlertType.UsageExceeded, "cost_exceeded" => AlertType.CostExceeded, + "license_balance_threshold_reached" => AlertType.LicenseBalanceThresholdReached, _ => (AlertType)(-1), }; } @@ -430,6 +476,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)) ), @@ -480,8 +527,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) { @@ -511,3 +561,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); +} diff --git a/src/Orb/Models/Alerts/AlertCreateForCustomerParams.cs b/src/Orb/Models/Alerts/AlertCreateForCustomerParams.cs index 6fb70fe86..186b6efc8 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + public virtual bool Equals(AlertCreateForCustomerParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -154,12 +191,17 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// /// The type of alert to create. This must be a valid alert type. /// -[JsonConverter(typeof(global::Orb.Models.Alerts.TypeConverter))] +[JsonConverter(typeof(TypeConverter))] public enum Type { CreditBalanceDepleted, diff --git a/src/Orb/Models/Alerts/AlertCreateForExternalCustomerParams.cs b/src/Orb/Models/Alerts/AlertCreateForExternalCustomerParams.cs index 3e5cc7a05..d5fae8b4b 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,41 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +198,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..ac1e2aae6 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 @@ -69,6 +73,25 @@ public required ApiEnum Type init { this._rawBodyData.Set("type", value); } } + /// + /// The property keys to group cost alerts by. Only applicable for cost_exceeded alerts. + /// + public IReadOnlyList? GroupingKeys + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct>("grouping_keys"); + } + init + { + this._rawBodyData.Set?>( + "grouping_keys", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + /// /// The metric to track usage for. /// @@ -82,8 +105,24 @@ public string? MetricID init { this._rawBodyData.Set("metric_id", value); } } + /// + /// The pricing unit to use for grouped cost alerts. Required when grouping_keys + /// is set. + /// + public string? PricingUnitID + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("pricing_unit_id"); + } + init { this._rawBodyData.Set("pricing_unit_id", value); } + } + public AlertCreateForSubscriptionParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AlertCreateForSubscriptionParams( AlertCreateForSubscriptionParams alertCreateForSubscriptionParams ) @@ -93,6 +132,7 @@ AlertCreateForSubscriptionParams alertCreateForSubscriptionParams this._rawBodyData = new(alertCreateForSubscriptionParams._rawBodyData); } +#pragma warning restore CS8618 public AlertCreateForSubscriptionParams( IReadOnlyDictionary rawHeaderData, @@ -133,6 +173,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +231,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..1eac104fb 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,39 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +130,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..b83281d1f 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,39 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +130,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/AlertListPage.cs b/src/Orb/Models/Alerts/AlertListPage.cs index a7a6e9338..5b78aba57 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; @@ -62,5 +63,20 @@ 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) + { + 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/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/AlertListParams.cs b/src/Orb/Models/Alerts/AlertListParams.cs index 7bb864ca9..535f5bd4b 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,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(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 +223,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..c31e1ce1a 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Alerts/AlertUpdateParams.cs b/src/Orb/Models/Alerts/AlertUpdateParams.cs index 4ef7d2ad1..c852422ad 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,41 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/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..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,12 +84,16 @@ public override void Validate() { item.Validate(); } + _ = this.LicenseTypeID; } public Allocation() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Allocation(Allocation allocation) : base(allocation) { } +#pragma warning restore CS8618 public Allocation(IReadOnlyDictionary rawData) { @@ -166,8 +180,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 147e0d65b..af25f908b 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +289,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] @@ -260,12 +302,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); } } @@ -292,8 +334,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) { @@ -315,7 +360,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 +659,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,10 +694,10 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Beta.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() { @@ -666,12 +705,28 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + 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 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 +851,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 ) { @@ -827,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. /// @@ -843,12 +913,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); } } @@ -857,14 +927,18 @@ public long? PlanPhaseOrder public override void Validate() { this.AllocationPrice?.Validate(); + this.LicenseAllocationPrice?.Validate(); _ = this.PlanPhaseOrder; this.Price?.Validate(); } public AddPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AddPrice(AddPrice addPrice) : base(addPrice) { } +#pragma warning restore CS8618 public AddPrice(IReadOnlyDictionary rawData) { @@ -894,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(global::Orb.Models.Beta.PriceConverter))] -public record class Price : ModelBase +[JsonConverter(typeof(LicenseAllocationPriceConverter))] +public record class LicenseAllocationPrice : ModelBase { public object? Value { get; } = null; @@ -919,77 +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, - minimum: (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, - minimum: (x) => x.Name, - newPlanMinimumComposite: (x) => x.Name, + minimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name ); @@ -1001,36 +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, - minimum: (x) => x.BillableMetricID, - newPlanMinimumComposite: (x) => x.BillableMetricID, + minimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID ); @@ -1042,36 +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, - minimum: (x) => x.BilledInAdvance, - newPlanMinimumComposite: (x) => x.BilledInAdvance, + minimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance ); @@ -1083,36 +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, - minimum: (x) => x.BillingCycleConfiguration, - newPlanMinimumComposite: (x) => x.BillingCycleConfiguration, + minimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration ); @@ -1124,36 +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, - minimum: (x) => x.ConversionRate, - newPlanMinimumComposite: (x) => x.ConversionRate, + minimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate ); @@ -1165,36 +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, - minimum: (x) => x.Currency, - newPlanMinimumComposite: (x) => x.Currency, + minimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency ); @@ -1206,36 +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, - minimum: (x) => x.DimensionalPriceConfiguration, - newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, + minimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration ); @@ -1247,36 +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, - minimum: (x) => x.ExternalPriceID, - newPlanMinimumComposite: (x) => x.ExternalPriceID, + minimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID ); @@ -1288,36 +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, - minimum: (x) => x.FixedPriceQuantity, - newPlanMinimumComposite: (x) => x.FixedPriceQuantity, + minimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity ); @@ -1329,36 +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, - minimum: (x) => x.InvoiceGroupingKey, - newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, + minimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey ); @@ -1370,1005 +1473,977 @@ 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, - minimum: (x) => x.InvoicingCycleConfiguration, - newPlanMinimumComposite: (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( - 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, - minimum: (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) - { - this.Value = value; - this._element = element; - } - - public Price(NewPlanTieredPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Unit value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanBulkPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Tiered value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(global::Orb.Models.Beta.BulkWithFilters value, JsonElement? element = null) + public LicenseAllocationPrice(Bulk value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(BulkWithFilters value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMatrixPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Package value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Matrix value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanTieredPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(ThresholdTotalAmount value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredPackage value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedTieredPrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredWithMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanTieredPackageWithMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedTiered value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredPackageWithMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanUnitWithPercentPrice value, JsonElement? element = null) + public LicenseAllocationPrice(PackageWithAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(UnitWithPercent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(global::Orb.Models.Beta.TieredWithProration value, JsonElement? element = null) + public LicenseAllocationPrice(MatrixWithAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanUnitWithProrationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedAllocationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(UnitWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanBulkWithProrationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedWithProratedMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(BulkWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedWithMeteredMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedWithProratedMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price( - global::Orb.Models.Beta.GroupedWithMinMaxThresholds value, - JsonElement? element = null - ) + public LicenseAllocationPrice(GroupedWithMeteredMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedWithMinMaxThresholds value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(MatrixWithDisplayName value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedTieredPackage value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanScalableMatrixWithUnitPricingPrice value, JsonElement? element = null) + public LicenseAllocationPrice(MaxGroupTieredPackage value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanScalableMatrixWithTieredPricingPrice value, JsonElement? element = null) + public LicenseAllocationPrice(ScalableMatrixWithUnitPricing value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) + public LicenseAllocationPrice( + ScalableMatrixWithTieredPricing value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public Price( - global::Orb.Models.Beta.CumulativeGroupedAllocation value, - JsonElement? element = null - ) + public LicenseAllocationPrice(CumulativeGroupedBulk value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(global::Orb.Models.Beta.Minimum 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(global::Orb.Models.Beta.Percent value, JsonElement? element = null) + public LicenseAllocationPrice(Percent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(global::Orb.Models.Beta.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; } /// /// 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; } /// /// 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; } /// /// 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; } /// /// 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; } /// /// 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; } /// /// 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; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.CumulativeGroupedAllocation` + /// // `value` is of type `CumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out global::Orb.Models.Beta.CumulativeGroupedAllocation? value + [NotNullWhen(true)] out CumulativeGroupedAllocation? value ) { - value = this.Value as global::Orb.Models.Beta.CumulativeGroupedAllocation; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.Minimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out global::Orb.Models.Beta.Minimum? value) - { - value = this.Value as global::Orb.Models.Beta.Minimum; + value = this.Value as CumulativeGroupedAllocation; return value != null; } /// /// 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; } /// /// 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; } @@ -2386,177 +2461,174 @@ public bool TryPickEventOutput( /// /// /// instance.Switch( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.BulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Beta.TieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Beta.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) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.Percent value) => {...}, - /// (global::Orb.Models.Beta.EventOutput value) => {...} + /// (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 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 + 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 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 global::Orb.Models.Beta.BulkWithFilters value: + 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 global::Orb.Models.Beta.TieredWithProration value: + 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 global::Orb.Models.Beta.GroupedWithMinMaxThresholds value: + 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 global::Orb.Models.Beta.CumulativeGroupedAllocation value: + case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case global::Orb.Models.Beta.Minimum value: - minimum(value); + case MinimumComposite value: + minimumComposite(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: - throw new OrbInvalidDataException("Data did not match any variant of Price"); + throw new OrbInvalidDataException( + "Data did not match any variant of LicenseAllocationPrice" + ); } } @@ -2575,256 +2647,189 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.BulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Beta.TieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Beta.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) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.Percent value) => {...}, - /// (global::Orb.Models.Beta.EventOutput value) => {...} + /// (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 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< - global::Orb.Models.Beta.GroupedWithMinMaxThresholds, - T - > groupedWithMinMaxThresholds, - System::Func newPlanMatrixWithDisplayName, - System::Func newPlanGroupedTieredPackage, - System::Func newPlanMaxGroupTieredPackage, - System::Func< - NewPlanScalableMatrixWithUnitPricingPrice, - T - > newPlanScalableMatrixWithUnitPricing, - System::Func< - NewPlanScalableMatrixWithTieredPricingPrice, - T - > newPlanScalableMatrixWithTieredPricing, - System::Func newPlanCumulativeGroupedBulk, - System::Func< - global::Orb.Models.Beta.CumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, - System::Func newPlanMinimumComposite, - System::Func percent, - System::Func eventOutput + 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 { - NewPlanUnitPrice value => newPlanUnit(value), - NewPlanTieredPrice value => newPlanTiered(value), - NewPlanBulkPrice value => newPlanBulk(value), - global::Orb.Models.Beta.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), - global::Orb.Models.Beta.TieredWithProration value => tieredWithProration(value), - NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), - NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), - NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), - NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( - value - ), - NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), - global::Orb.Models.Beta.GroupedWithMinMaxThresholds value => - groupedWithMinMaxThresholds(value), - NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), - NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), - NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), - NewPlanScalableMatrixWithUnitPricingPrice value => newPlanScalableMatrixWithUnitPricing( - value + 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" ), - NewPlanScalableMatrixWithTieredPricingPrice value => - newPlanScalableMatrixWithTieredPricing(value), - NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), - global::Orb.Models.Beta.CumulativeGroupedAllocation value => - cumulativeGroupedAllocation(value), - global::Orb.Models.Beta.Minimum value => minimum(value), - NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), - global::Orb.Models.Beta.Percent value => percent(value), - global::Orb.Models.Beta.EventOutput value => eventOutput(value), - _ => throw new OrbInvalidDataException("Data did not match any variant of Price"), }; } - public static implicit operator global::Orb.Models.Beta.Price(NewPlanUnitPrice value) => - new(value); - - public static implicit operator global::Orb.Models.Beta.Price(NewPlanTieredPrice value) => - new(value); + public static implicit operator LicenseAllocationPrice(Unit value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price(NewPlanBulkPrice value) => - new(value); + public static implicit operator LicenseAllocationPrice(Tiered value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.BulkWithFilters value - ) => new(value); + public static implicit operator LicenseAllocationPrice(Bulk value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price(NewPlanPackagePrice value) => - new(value); + public static implicit operator LicenseAllocationPrice(BulkWithFilters value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price(NewPlanMatrixPrice value) => - new(value); + public static implicit operator LicenseAllocationPrice(Package value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanThresholdTotalAmountPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(Matrix value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanTieredPackagePrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(ThresholdTotalAmount value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanTieredWithMinimumPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(TieredPackage value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedTieredPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(TieredWithMinimum value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanTieredPackageWithMinimumPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedTiered value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanPackageWithAllocationPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(TieredPackageWithMinimum value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanUnitWithPercentPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(PackageWithAllocation value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanMatrixWithAllocationPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(UnitWithPercent value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.TieredWithProration value - ) => new(value); + public static implicit operator LicenseAllocationPrice(MatrixWithAllocation value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanUnitWithProrationPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(TieredWithProration value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedAllocationPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(UnitWithProration value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanBulkWithProrationPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedAllocation value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(BulkWithProration value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedWithProratedMinimum value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.GroupedWithMinMaxThresholds value - ) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedWithMeteredMinimum value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanMatrixWithDisplayNamePrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedWithMinMaxThresholds value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanGroupedTieredPackagePrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(MatrixWithDisplayName value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanMaxGroupTieredPackagePrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedTieredPackage value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(MaxGroupTieredPackage value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(ScalableMatrixWithUnitPricing value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanCumulativeGroupedBulkPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(ScalableMatrixWithTieredPricing value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.CumulativeGroupedAllocation value - ) => new(value); + public static implicit operator LicenseAllocationPrice(CumulativeGroupedBulk value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.Minimum value - ) => new(value); + public static implicit operator LicenseAllocationPrice(CumulativeGroupedAllocation value) => + new(value); - public static implicit operator global::Orb.Models.Beta.Price( - NewPlanMinimumCompositePrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(MinimumComposite value) => new(value); - public static implicit operator global::Orb.Models.Beta.Price( - global::Orb.Models.Beta.Percent value - ) => new(value); + public static implicit operator LicenseAllocationPrice(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 LicenseAllocationPrice(EventOutput value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2840,50 +2845,49 @@ 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(), - (minimum) => minimum.Validate(), - (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), + (minimumComposite) => minimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() ); } - public virtual bool Equals(global::Orb.Models.Beta.Price? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(LicenseAllocationPrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2891,12 +2895,54 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + 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 PriceConverter : JsonConverter +sealed class LicenseAllocationPriceConverter : JsonConverter { - public override global::Orb.Models.Beta.Price? Read( + public override LicenseAllocationPrice? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2919,10 +2965,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2941,10 +2984,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2963,10 +3003,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2985,11 +3022,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3008,10 +3044,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3030,10 +3063,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3052,7 +3082,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3074,10 +3104,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3096,7 +3123,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3118,10 +3145,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3140,11 +3164,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3163,11 +3186,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3186,7 +3208,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3208,7 +3230,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3230,11 +3252,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3253,7 +3274,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3275,7 +3296,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3297,7 +3318,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3319,11 +3340,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3342,11 +3362,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3365,11 +3384,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3388,11 +3406,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3411,7 +3428,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3433,11 +3450,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3456,11 +3472,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3479,11 +3494,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3502,11 +3516,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3525,30 +3538,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3570,7 +3560,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3592,10 +3582,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3614,11 +3601,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3635,14 +3618,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.Price(element); + return new LicenseAllocationPrice(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.Price? value, + LicenseAllocationPrice? value, JsonSerializerOptions options ) { @@ -3650,55 +3633,56 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.BulkWithFilters, - global::Orb.Models.Beta.BulkWithFiltersFromRaw - >) -)] -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 global::Orb.Models.Beta.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); } } /// @@ -3727,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. /// @@ -3786,14 +3783,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); } } @@ -3882,6 +3877,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 @@ -3920,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(); @@ -3944,375 +3951,194 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public BulkWithFilters() + public Unit() { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("unit"); } - public BulkWithFilters(global::Orb.Models.Beta.BulkWithFilters bulkWithFilters) - : base(bulkWithFilters) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Beta.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Unit FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class BulkWithFiltersFromRaw : IFromRawJson +class UnitFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.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< - global::Orb.Models.Beta.BulkWithFiltersConfig, - global::Orb.Models.Beta.BulkWithFiltersConfigFromRaw - >) -)] -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) - ); - } - } - - /// - public override void Validate() - { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public BulkWithFiltersConfig() { } + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} - public BulkWithFiltersConfig( - global::Orb.Models.Beta.BulkWithFiltersConfig bulkWithFiltersConfig +sealed class CadenceConverter : JsonConverter +{ + public override Cadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) - : base(bulkWithFiltersConfig) { } - - public BulkWithFiltersConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkWithFiltersConfig(FrozenDictionary rawData) { - this._rawData = new(rawData); + 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), + }; } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.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 global::Orb.Models.Beta.BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.BulkWithFiltersConfig.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a single property filter -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.Filter, - global::Orb.Models.Beta.FilterFromRaw - >) -)] -public sealed record class Filter : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseAllocation : 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 + /// The amount of credits granted per active license per cadence. /// - public required string PropertyValue + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("property_value", value); } - } - - /// - public override void Validate() - { - _ = this.PropertyKey; - _ = this.PropertyValue; - } - - public Filter() { } - - public Filter(global::Orb.Models.Beta.Filter filter) - : base(filter) { } - - 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 global::Orb.Models.Beta.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + init { this._rawData.Set("amount", value); } } -} - -class FilterFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Filter.FromRawUnchecked(rawData); -} -/// -/// Configuration for a single bulk pricing tier -/// -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class Tier : JsonModel -{ /// - /// Amount per unit + /// The currency of the license allocation. /// - public required string UnitAmount + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("currency"); } - 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() { } - public Tier(global::Orb.Models.Beta.Tier tier) - : base(tier) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Beta.Tier FromRawUnchecked( + /// + 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 global::Orb.Models.Beta.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Tier.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(global::Orb.Models.Beta.CadenceConverter))] -public enum Cadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class CadenceConverter : JsonConverter -{ - public override global::Orb.Models.Beta.Cadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - 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), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.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", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } + public LicenseAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => + LicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.ConversionRateConfigConverter))] +[JsonConverter(typeof(ConversionRateConfigConverter))] public record class ConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4465,13 +4291,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,10 +4318,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Beta.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() { @@ -4505,13 +4329,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -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 +4412,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 +4427,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.TieredWithProration, - global::Orb.Models.Beta.TieredWithProrationFromRaw - >) -)] -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< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -4627,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 /// @@ -4654,18 +4506,16 @@ public required string Name } /// - /// Configuration for tiered_with_proration pricing + /// Configuration for tiered pricing /// - public required global::Orb.Models.Beta.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); } } /// @@ -4727,12 +4577,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 TieredConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4823,6 +4673,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 @@ -4863,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(); @@ -4885,55 +4747,56 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public TieredWithProration() + public Tiered() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("tiered"); } - public TieredWithProration(global::Orb.Models.Beta.TieredWithProration tieredWithProration) - : base(tieredWithProration) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Beta.TieredWithProration FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Tiered FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class TieredWithProrationFromRaw : IFromRawJson +class TieredFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.TieredWithProration FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.TieredWithProration.FromRawUnchecked(rawData); + public Tiered FromRawUnchecked(IReadOnlyDictionary rawData) => + Tiered.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.TieredWithProrationCadenceConverter))] -public enum TieredWithProrationCadence +[JsonConverter(typeof(TieredCadenceConverter))] +public enum TieredCadence { Annual, SemiAnnual, @@ -4943,10 +4806,9 @@ public enum TieredWithProrationCadence Custom, } -sealed class TieredWithProrationCadenceConverter - : JsonConverter +sealed class TieredCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.TieredWithProrationCadence Read( + public override TieredCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4954,19 +4816,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" => 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, - global::Orb.Models.Beta.TieredWithProrationCadence value, + TieredCadence value, JsonSerializerOptions options ) { @@ -4974,12 +4836,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", + 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)) ), @@ -4989,160 +4851,79 @@ JsonSerializerOptions options } } -/// -/// Configuration for tiered_with_proration pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.TieredWithProrationConfig, - global::Orb.Models.Beta.TieredWithProrationConfigFromRaw - >) -)] -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< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + return this._rawData.GetNotNullClass("amount"); } + init { this._rawData.Set("amount", value); } } - /// - public override void Validate() - { - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public TieredWithProrationConfig() { } - - public TieredWithProrationConfig( - global::Orb.Models.Beta.TieredWithProrationConfig tieredWithProrationConfig - ) - : base(tieredWithProrationConfig) { } - - 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 global::Orb.Models.Beta.TieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public TieredWithProrationConfig( - IReadOnlyList tiers - ) - : this() - { - this.Tiers = tiers; - } -} - -class TieredWithProrationConfigFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.TieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.TieredWithProrationConfig.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a single tiered with proration tier -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.TieredWithProrationConfigTier, - global::Orb.Models.Beta.TieredWithProrationConfigTierFromRaw - >) -)] -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() { } - public TieredWithProrationConfigTier( - global::Orb.Models.Beta.TieredWithProrationConfigTier tieredWithProrationConfigTier - ) - : base(tieredWithProrationConfigTier) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Beta.TieredWithProrationConfigTier FromRawUnchecked( + /// + public static TieredLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5150,17 +4931,16 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationConfigTierFromRaw - : IFromRawJson +class TieredLicenseAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.TieredWithProrationConfigTier FromRawUnchecked( + public TieredLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.TieredWithProrationConfigTier.FromRawUnchecked(rawData); + ) => TieredLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.TieredWithProrationConversionRateConfigConverter))] -public record class TieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(TieredConversionRateConfigConverter))] +public record class TieredConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5177,7 +4957,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public TieredConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5186,7 +4966,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public TieredConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5195,7 +4975,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public TieredConversionRateConfig(JsonElement element) { this._element = element; } @@ -5277,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" ); } } @@ -5313,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 global::Orb.Models.Beta.TieredWithProrationConversionRateConfig( + public static implicit operator TieredConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.TieredWithProrationConversionRateConfig( + public static implicit operator TieredConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5341,18 +5121,16 @@ 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( - global::Orb.Models.Beta.TieredWithProrationConversionRateConfig? 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() { @@ -5360,13 +5138,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class TieredWithProrationConversionRateConfigConverter - : JsonConverter +sealed class TieredConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Beta.TieredWithProrationConversionRateConfig? Read( + public override TieredConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5431,14 +5221,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.TieredWithProrationConversionRateConfig(element); + return new TieredConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.TieredWithProrationConversionRateConfig value, + TieredConversionRateConfig value, JsonSerializerOptions options ) { @@ -5446,45 +5236,33 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.GroupedWithMinMaxThresholds, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsFromRaw - >) -)] -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< - string, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence - > 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 global::Orb.Models.Beta.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); } } /// @@ -5500,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 /// @@ -5585,12 +5386,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 BulkConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5681,6 +5482,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 @@ -5719,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"); } @@ -5743,58 +5556,56 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public GroupedWithMinMaxThresholds() + public Bulk() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("bulk"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Beta.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) - : base(groupedWithMinMaxThresholds) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Beta.GroupedWithMinMaxThresholds FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Bulk FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class BulkFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.GroupedWithMinMaxThresholds FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + public Bulk FromRawUnchecked(IReadOnlyDictionary rawData) => + Bulk.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadenceConverter))] -public enum GroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(BulkCadenceConverter))] +public enum BulkCadence { Annual, SemiAnnual, @@ -5804,10 +5615,9 @@ public enum GroupedWithMinMaxThresholdsCadence Custom, } -sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class BulkCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence Read( + public override BulkCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5815,19 +5625,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" => 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, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence value, + BulkCadence value, JsonSerializerOptions options ) { @@ -5835,13 +5645,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", + 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)) ), @@ -5851,100 +5660,79 @@ JsonSerializerOptions options } } -/// -/// Configuration for grouped_with_min_max_thresholds pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Beta.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 + /// The amount of credits granted per active license per cadence. /// - public required string GroupingKey + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("amount", value); } } /// - /// The maximum amount to charge each group + /// The currency of the license allocation. /// - public required string MaximumCharge + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + return this._rawData.GetNotNullClass("currency"); } - 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); } + 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() { } - public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig - ) - : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static BulkLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5952,19 +5740,16 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class BulkLicenseAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public BulkLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); + ) => BulkLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] -public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(BulkConversionRateConfigConverter))] +public record class BulkConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5981,7 +5766,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public BulkConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5990,7 +5775,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public BulkConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5999,7 +5784,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public BulkConversionRateConfig(JsonElement element) { this._element = element; } @@ -6081,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" ); } } @@ -6117,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 global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator BulkConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator BulkConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6145,18 +5930,16 @@ 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( - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig? 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() { @@ -6164,13 +5947,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class BulkConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override BulkConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6235,16 +6030,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new BulkConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig value, + BulkConversionRateConfig value, JsonSerializerOptions options ) { @@ -6252,45 +6045,35 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.CumulativeGroupedAllocation, - global::Orb.Models.Beta.CumulativeGroupedAllocationFromRaw - >) -)] -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< - string, - global::Orb.Models.Beta.CumulativeGroupedAllocationCadence - > 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 global::Orb.Models.Beta.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); } } /// @@ -6306,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 /// @@ -6391,12 +6197,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 BulkWithFiltersConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6487,6 +6293,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 @@ -6525,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") ) ) { @@ -6549,37 +6372,131 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public CumulativeGroupedAllocation() + public BulkWithFilters() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Beta.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) - : base(cumulativeGroupedAllocation) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Beta.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 ) { @@ -6587,20 +6504,174 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class BulkWithFiltersConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.CumulativeGroupedAllocation FromRawUnchecked( + public BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.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(global::Orb.Models.Beta.CumulativeGroupedAllocationCadenceConverter))] -public enum CumulativeGroupedAllocationCadence +[JsonConverter(typeof(BulkWithFiltersCadenceConverter))] +public enum BulkWithFiltersCadence { Annual, SemiAnnual, @@ -6610,10 +6681,9 @@ public enum CumulativeGroupedAllocationCadence Custom, } -sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class BulkWithFiltersCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.CumulativeGroupedAllocationCadence Read( + public override BulkWithFiltersCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6621,19 +6691,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" => 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, - global::Orb.Models.Beta.CumulativeGroupedAllocationCadence value, + BulkWithFiltersCadence value, JsonSerializerOptions options ) { @@ -6641,13 +6711,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", + 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)) ), @@ -6657,100 +6726,86 @@ JsonSerializerOptions options } } -/// -/// Configuration for cumulative_grouped_allocation pricing -/// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.CumulativeGroupedAllocationConfig, - global::Orb.Models.Beta.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 - { - 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 + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("group_allocation", value); } + init { this._rawData.Set("amount", value); } } /// - /// The event property used to group usage before applying allocations + /// The currency of the license allocation. /// - public required string GroupingKey + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("currency"); } - 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() { } - public CumulativeGroupedAllocationConfig( - global::Orb.Models.Beta.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Beta.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static BulkWithFiltersLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6758,19 +6813,16 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class BulkWithFiltersLicenseAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.CumulativeGroupedAllocationConfig FromRawUnchecked( + public BulkWithFiltersLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); + ) => BulkWithFiltersLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfigConverter) -)] -public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(BulkWithFiltersConversionRateConfigConverter))] +public record class BulkWithFiltersConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6787,7 +6839,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public BulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6796,7 +6848,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public BulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6805,7 +6857,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public BulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -6887,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" ); } } @@ -6923,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 global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator BulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator BulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6951,18 +7003,16 @@ 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( - global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig? 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() { @@ -6970,13 +7020,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class CumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class BulkWithFiltersConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig? Read( + public override BulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7041,16 +7104,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig( - element - ); + return new BulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig value, + BulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -7058,23 +7119,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.Minimum, - global::Orb.Models.Beta.MinimumFromRaw - >) -)] -public sealed record class Minimum : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class 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); } } @@ -7093,18 +7149,26 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// 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 global::Orb.Models.Beta.MinimumConfig MinimumConfig + public required IReadOnlyList LicenseAllocations { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) ); } - init { this._rawData.Set("minimum_config", value); } } /// @@ -7133,6 +7197,19 @@ public required string 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. /// @@ -7192,12 +7269,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public MinimumConversionRateConfig? ConversionRateConfig + public PackageConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7288,6 +7365,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 @@ -7328,12 +7418,16 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + 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(); @@ -7345,55 +7439,56 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Minimum() + public Package() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("package"); } - public Minimum(global::Orb.Models.Beta.Minimum minimum) - : base(minimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Package(Package package) + : base(package) { } +#pragma warning restore CS8618 - public Minimum(IReadOnlyDictionary rawData) + public Package(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("package"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + Package(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Package FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class PackageFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Minimum.FromRawUnchecked(rawData); + public Package FromRawUnchecked(IReadOnlyDictionary rawData) => + Package.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(MinimumCadenceConverter))] -public enum MinimumCadence +[JsonConverter(typeof(PackageCadenceConverter))] +public enum PackageCadence { Annual, SemiAnnual, @@ -7403,9 +7498,9 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter : JsonConverter +sealed class PackageCadenceConverter : JsonConverter { - public override MinimumCadence Read( + public override PackageCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7413,19 +7508,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" => 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, - MinimumCadence value, + PackageCadence value, JsonSerializerOptions options ) { @@ -7433,12 +7528,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", + 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)) ), @@ -7448,102 +7543,98 @@ JsonSerializerOptions options } } -/// -/// Configuration for minimum pricing -/// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.MinimumConfig, - global::Orb.Models.Beta.MinimumConfigFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class MinimumConfig : JsonModel +public sealed record class PackageLicenseAllocation : JsonModel { /// - /// The minimum amount to apply + /// The amount of credits granted per active license per cadence. /// - public required string MinimumAmount + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("amount", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// The currency of the license allocation. /// - public bool? Prorated + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNotNullClass("currency"); } - init - { - if (value == null) - { - return; - } + init { this._rawData.Set("currency", value); } + } - this._rawData.Set("prorated", 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.MinimumAmount; - _ = this.Prorated; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public MinimumConfig() { } + public PackageLicenseAllocation() { } - public MinimumConfig(global::Orb.Models.Beta.MinimumConfig minimumConfig) - : base(minimumConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PackageLicenseAllocation(PackageLicenseAllocation packageLicenseAllocation) + : base(packageLicenseAllocation) { } +#pragma warning restore CS8618 - public MinimumConfig(IReadOnlyDictionary rawData) + public PackageLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + PackageLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.MinimumConfig FromRawUnchecked( + /// + public static PackageLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class MinimumConfigFromRaw : IFromRawJson +class PackageLicenseAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.MinimumConfig FromRawUnchecked( + public PackageLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.MinimumConfig.FromRawUnchecked(rawData); + ) => PackageLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(PackageConversionRateConfigConverter))] +public record class PackageConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7560,7 +7651,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public PackageConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7569,7 +7660,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public PackageConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7578,7 +7669,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public PackageConversionRateConfig(JsonElement element) { this._element = element; } @@ -7660,7 +7751,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PackageConversionRateConfig" ); } } @@ -7696,16 +7787,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 PackageConversionRateConfig" ), }; } - public static implicit operator MinimumConversionRateConfig( + public static implicit operator PackageConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator MinimumConversionRateConfig( + public static implicit operator PackageConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7724,16 +7815,16 @@ 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 PackageConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(MinimumConversionRateConfig? 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() { @@ -7741,12 +7832,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class MinimumConversionRateConfigConverter : JsonConverter +sealed class PackageConversionRateConfigConverter : JsonConverter { - public override MinimumConversionRateConfig? Read( + public override PackageConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7811,14 +7915,14 @@ JsonSerializerOptions options } default: { - return new MinimumConversionRateConfig(element); + return new PackageConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MinimumConversionRateConfig value, + PackageConversionRateConfig value, JsonSerializerOptions options ) { @@ -7826,25 +7930,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.Percent, - global::Orb.Models.Beta.PercentFromRaw - >) -)] -public sealed record class Percent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class 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< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -7863,44 +7960,65 @@ public required string ItemID } /// - /// The pricing model type + /// 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 JsonElement ModelType + public required IReadOnlyList LicenseAllocations { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("model_type", value); } } /// - /// The name of the price. + /// Configuration for matrix pricing /// - public required string Name + public required MatrixConfig MatrixConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNotNullClass("matrix_config"); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("matrix_config", value); } } /// - /// Configuration for percent pricing + /// The pricing model type /// - public required global::Orb.Models.Beta.PercentConfig PercentConfig + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("percent_config", value); } + 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); } } /// @@ -7962,12 +8080,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 MatrixConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8058,6 +8176,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 @@ -8098,12 +8229,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(); + } + this.MatrixConfig.Validate(); + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("matrix"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -8115,55 +8250,56 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Percent() + public Matrix() { - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("matrix"); } - public Percent(global::Orb.Models.Beta.Percent percent) - : base(percent) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Matrix(Matrix matrix) + : base(matrix) { } +#pragma warning restore CS8618 - public Percent(IReadOnlyDictionary rawData) + public Matrix(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("matrix"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Percent(FrozenDictionary rawData) + Matrix(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Matrix FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class MatrixFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Percent.FromRawUnchecked(rawData); + public Matrix FromRawUnchecked(IReadOnlyDictionary rawData) => + Matrix.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(MatrixCadenceConverter))] +public enum MatrixCadence { Annual, SemiAnnual, @@ -8173,9 +8309,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter : JsonConverter +sealed class MatrixCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.PercentCadence Read( + public override MatrixCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8183,19 +8319,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" => 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, - global::Orb.Models.Beta.PercentCadence value, + MatrixCadence value, JsonSerializerOptions options ) { @@ -8203,12 +8339,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", + 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)) ), @@ -8218,80 +8354,96 @@ JsonSerializerOptions options } } -/// -/// Configuration for percent pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.PercentConfig, - global::Orb.Models.Beta.PercentConfigFromRaw - >) -)] -public sealed record class PercentConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixLicenseAllocation : 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 MatrixLicenseAllocation() { } - public PercentConfig(global::Orb.Models.Beta.PercentConfig percentConfig) - : base(percentConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixLicenseAllocation(MatrixLicenseAllocation matrixLicenseAllocation) + : base(matrixLicenseAllocation) { } +#pragma warning restore CS8618 - public PercentConfig(IReadOnlyDictionary rawData) + public MatrixLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PercentConfig(FrozenDictionary rawData) + MatrixLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.PercentConfig FromRawUnchecked( + /// + public static MatrixLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public PercentConfig(double percent) - : this() - { - this.Percent = percent; - } } -class PercentConfigFromRaw : IFromRawJson +class MatrixLicenseAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.PercentConfig FromRawUnchecked( + public MatrixLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.PercentConfig.FromRawUnchecked(rawData); + ) => MatrixLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +[JsonConverter(typeof(MatrixConversionRateConfigConverter))] +public record class MatrixConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8308,7 +8460,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public MatrixConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8317,7 +8469,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public MatrixConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8326,7 +8478,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public MatrixConversionRateConfig(JsonElement element) { this._element = element; } @@ -8408,7 +8560,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of MatrixConversionRateConfig" ); } } @@ -8444,16 +8596,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 MatrixConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.PercentConversionRateConfig( + public static implicit operator MatrixConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.PercentConversionRateConfig( + public static implicit operator MatrixConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8472,16 +8624,16 @@ 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 MatrixConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Beta.PercentConversionRateConfig? 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() { @@ -8489,13 +8641,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class PercentConversionRateConfigConverter - : JsonConverter +sealed class MatrixConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Beta.PercentConversionRateConfig? Read( + public override MatrixConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8560,14 +8724,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.PercentConversionRateConfig(element); + return new MatrixConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.PercentConversionRateConfig value, + MatrixConversionRateConfig value, JsonSerializerOptions options ) { @@ -8575,55 +8739,58 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.EventOutput, - global::Orb.Models.Beta.EventOutputFromRaw - >) -)] -public sealed record class EventOutput : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ThresholdTotalAmount : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } /// - /// Configuration for event_output pricing + /// The id of the item the price will be associated with. /// - public required global::Orb.Models.Beta.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< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("item_id", value); } } /// @@ -8652,6 +8819,21 @@ public required string 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. /// @@ -8711,12 +8893,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 ThresholdTotalAmountConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8807,6 +8989,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 @@ -8846,18 +9041,22 @@ public string? ReferenceID 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") + 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(); @@ -8869,35 +9068,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public EventOutput() + public ThresholdTotalAmount() { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); } - public EventOutput(global::Orb.Models.Beta.EventOutput eventOutput) - : base(eventOutput) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdTotalAmount(ThresholdTotalAmount thresholdTotalAmount) + : base(thresholdTotalAmount) { } +#pragma warning restore CS8618 - public EventOutput(IReadOnlyDictionary rawData) + public ThresholdTotalAmount(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) + ThresholdTotalAmount(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.EventOutput FromRawUnchecked( + /// + public static ThresholdTotalAmount FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8905,19 +9108,19 @@ IReadOnlyDictionary rawData } } -class EventOutputFromRaw : IFromRawJson +class ThresholdTotalAmountFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.EventOutput FromRawUnchecked( + public ThresholdTotalAmount FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.EventOutput.FromRawUnchecked(rawData); + ) => ThresholdTotalAmount.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.EventOutputCadenceConverter))] -public enum EventOutputCadence +[JsonConverter(typeof(ThresholdTotalAmountCadenceConverter))] +public enum ThresholdTotalAmountCadence { Annual, SemiAnnual, @@ -8927,9 +9130,9 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter : JsonConverter +sealed class ThresholdTotalAmountCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.EventOutputCadence Read( + public override ThresholdTotalAmountCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8937,19 +9140,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" => 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, - global::Orb.Models.Beta.EventOutputCadence value, + ThresholdTotalAmountCadence value, JsonSerializerOptions options ) { @@ -8957,12 +9160,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", + 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)) ), @@ -8972,111 +9175,275 @@ JsonSerializerOptions options } } -/// -/// Configuration for event_output pricing -/// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.EventOutputConfig, - global::Orb.Models.Beta.EventOutputConfigFromRaw + ThresholdTotalAmountLicenseAllocation, + ThresholdTotalAmountLicenseAllocationFromRaw >) )] -public sealed record class EventOutputConfig : JsonModel +public sealed record class ThresholdTotalAmountLicenseAllocation : 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 ThresholdTotalAmountLicenseAllocation() { } - public EventOutputConfig(global::Orb.Models.Beta.EventOutputConfig eventOutputConfig) - : base(eventOutputConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdTotalAmountLicenseAllocation( + ThresholdTotalAmountLicenseAllocation thresholdTotalAmountLicenseAllocation + ) + : base(thresholdTotalAmountLicenseAllocation) { } +#pragma warning restore CS8618 - public EventOutputConfig(IReadOnlyDictionary rawData) + public ThresholdTotalAmountLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutputConfig(FrozenDictionary rawData) + ThresholdTotalAmountLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.EventOutputConfig FromRawUnchecked( + /// + 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 EventOutputConfig(string unitRatingKey) + 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.UnitRatingKey = unitRatingKey; + this.ConsumptionTable = consumptionTable; } } -class EventOutputConfigFromRaw : IFromRawJson +class ThresholdTotalAmountConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.EventOutputConfig FromRawUnchecked( + public ThresholdTotalAmountConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.EventOutputConfig.FromRawUnchecked(rawData); + ) => ThresholdTotalAmountConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.EventOutputConversionRateConfigConverter))] -public record class EventOutputConversionRateConfig : ModelBase +/// +/// 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; @@ -9093,7 +9460,7 @@ public JsonElement Json } } - public EventOutputConversionRateConfig( + public ThresholdTotalAmountConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9102,7 +9469,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig( + public ThresholdTotalAmountConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9111,7 +9478,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig(JsonElement element) + public ThresholdTotalAmountConversionRateConfig(JsonElement element) { this._element = element; } @@ -9193,7 +9560,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of ThresholdTotalAmountConversionRateConfig" ); } } @@ -9229,16 +9596,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 ThresholdTotalAmountConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.EventOutputConversionRateConfig( + public static implicit operator ThresholdTotalAmountConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.EventOutputConversionRateConfig( + public static implicit operator ThresholdTotalAmountConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -9257,16 +9624,16 @@ 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 ThresholdTotalAmountConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Beta.EventOutputConversionRateConfig? 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() { @@ -9274,13 +9641,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class EventOutputConversionRateConfigConverter - : JsonConverter +sealed class ThresholdTotalAmountConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.EventOutputConversionRateConfig? Read( + public override ThresholdTotalAmountConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9345,14 +9725,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.EventOutputConversionRateConfig(element); + return new ThresholdTotalAmountConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.EventOutputConversionRateConfig value, + ThresholdTotalAmountConversionRateConfig value, JsonSerializerOptions options ) { @@ -9360,428 +9740,769 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemoveAdjustment : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredPackage : 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); } - } - - /// - 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; + init { this._rawData.Set("item_id", value); } } -} - -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. + /// 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 PriceID + public required IReadOnlyList LicenseAllocations { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("price_id"); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("price_id", value); } } /// - /// The phase to remove this price from. + /// The pricing model type /// - public long? PlanPhaseOrder + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("plan_phase_order", value); } - } - - /// - public override void Validate() - { - _ = this.PriceID; - _ = this.PlanPhaseOrder; + init { this._rawData.Set("model_type", value); } } - public RemovePrice() { } - - public RemovePrice(RemovePrice removePrice) - : base(removePrice) { } - - public RemovePrice(IReadOnlyDictionary rawData) + /// + /// The name of the price. + /// + public required string Name { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemovePrice(FrozenDictionary rawData) + /// + /// Configuration for tiered_package pricing + /// + public required TieredPackageConfig TieredPackageConfig { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tiered_package_config"); + } + init { this._rawData.Set("tiered_package_config", value); } } -#pragma warning restore CS8618 - /// - public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } } - [SetsRequiredMembers] - public RemovePrice(string priceID) - : this() + /// + /// 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.PriceID = priceID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", 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 plan. + /// For custom cadence: specifies the duration of the billing period in days + /// or months. /// - public required ReplaceAdjustmentAdjustment Adjustment + public NewBillingCycleConfiguration? BillingCycleConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment"); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); } - init { this._rawData.Set("adjustment", value); } + init { this._rawData.Set("billing_cycle_configuration", value); } } /// - /// The id of the adjustment on the plan to replace in the plan. + /// The per unit conversion rate of the price currency to the invoicing currency. /// - public required string ReplacesAdjustmentID + public double? ConversionRate { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); + return this._rawData.GetNullableStruct("conversion_rate"); } - init { this._rawData.Set("replaces_adjustment_id", value); } + init { this._rawData.Set("conversion_rate", value); } } /// - /// The phase to replace this adjustment from. + /// The configuration for the rate of the price currency to the invoicing currency. /// - public long? PlanPhaseOrder + public TieredPackageConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); } - init { this._rawData.Set("plan_phase_order", value); } + init { this._rawData.Set("conversion_rate_config", value); } } - /// - public override void Validate() + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; - _ = this.PlanPhaseOrder; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } } - public ReplaceAdjustment() { } - - public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) - : base(replaceAdjustment) { } - - public ReplaceAdjustment(IReadOnlyDictionary rawData) + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplaceAdjustment(FrozenDictionary rawData) + /// + /// An alias for the price. + /// + 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 ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + 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); } } -} - -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 + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); } + init { this._rawData.Set("invoice_grouping_key", value); } } - public string? Currency + /// + /// 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 { - return Match( - newPercentageDiscount: (x) => x.Currency, - newUsageDiscount: (x) => x.Currency, - newAmountDiscount: (x) => x.Currency, - newMinimum: (x) => x.Currency, - newMaximum: (x) => x.Currency + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" ); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - public bool? IsInvoiceLevel + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { 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.GetNullableClass("license_type_id"); } + init { this._rawData.Set("license_type_id", value); } } - public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) - { - this.Value = value; - this._element = element; + /// + /// User-specified key/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 ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); + } + init { this._rawData.Set("reference_id", value); } } - public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + 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 ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) + public TieredPackage() { - this.Value = value; - this._element = element; + this.ModelType = JsonSerializer.SerializeToElement("tiered_package"); } - public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackage(TieredPackage tieredPackage) + : base(tieredPackage) { } +#pragma warning restore CS8618 + + public TieredPackage(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_package"); } - public ReplaceAdjustmentAdjustment(JsonElement element) +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackage(FrozenDictionary rawData) { - this._element = element; + 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 +{ /// - /// Returns true and sets the 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); - /// } - /// - /// + /// The amount of credits granted per active license per cadence. /// - public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) + public required string Amount { - value = this.Value as NewPercentageDiscount; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("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); - /// } - /// - /// + /// The currency of the license allocation. /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + public required string Currency { - value = this.Value as NewUsageDiscount; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", 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.TryPickNewAmountDiscount(out var value)) { - /// // `value` is of type `NewAmountDiscount` - /// Console.WriteLine(value); - /// } - /// - /// + /// When True, overage beyond the allocation is written off. /// - public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + public bool? WriteOffOverage { - value = this.Value as NewAmountDiscount; - return value != null; + 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 . + /// 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; } @@ -9799,43 +10520,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 TieredPackageConversionRateConfig" ); } } @@ -9855,48 +10561,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 TieredPackageConversionRateConfig" ), }; } - 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 TieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); - public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum 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 @@ -9913,22 +10605,16 @@ 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 TieredPackageConversionRateConfig" ); } - 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) - { - 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() { @@ -9936,35 +10622,49 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter +sealed class TieredPackageConversionRateConfigConverter + : JsonConverter { - public override ReplaceAdjustmentAdjustment? Read( + public override TieredPackageConversionRateConfig? 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": + case "unit": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -9982,33 +10682,11 @@ JsonSerializerOptions options 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": + case "tiered": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -10026,54 +10704,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 TieredPackageConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplaceAdjustmentAdjustment value, + TieredPackageConversionRateConfig value, JsonSerializerOptions options ) { @@ -10081,1790 +10721,1849 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class ReplacePrice : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredWithMinimum : 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< + ImmutableArray + >("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() { } - - public ReplacePrice(ReplacePrice replacePrice) - : base(replacePrice) { } - - public ReplacePrice(IReadOnlyDictionary rawData) + /// + /// Configuration for tiered_with_minimum pricing + /// + public required TieredWithMinimumConfig TieredWithMinimumConfig { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_minimum_config" + ); + } + init { this._rawData.Set("tiered_with_minimum_config", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePrice(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 ReplacePrice 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 ReplacePrice(string replacesPriceID) - : this() + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration { - this.ReplacesPriceID = replacesPriceID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } } -} - -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; + /// + /// 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 JsonElement Json + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public TieredWithMinimumConversionRateConfig? ConversionRateConfig { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" ); } + init { this._rawData.Set("conversion_rate_config", value); } } - public string ItemID + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency { get { - return Match( - newPlanUnit: (x) => x.ItemID, - newPlanTiered: (x) => x.ItemID, - newPlanBulk: (x) => x.ItemID, - bulkWithFilters: (x) => x.ItemID, - newPlanPackage: (x) => x.ItemID, - newPlanMatrix: (x) => x.ItemID, - newPlanThresholdTotalAmount: (x) => x.ItemID, - newPlanTieredPackage: (x) => x.ItemID, - newPlanTieredWithMinimum: (x) => x.ItemID, - newPlanGroupedTiered: (x) => x.ItemID, - newPlanTieredPackageWithMinimum: (x) => x.ItemID, - newPlanPackageWithAllocation: (x) => x.ItemID, - newPlanUnitWithPercent: (x) => x.ItemID, - newPlanMatrixWithAllocation: (x) => x.ItemID, - tieredWithProration: (x) => x.ItemID, - newPlanUnitWithProration: (x) => x.ItemID, - newPlanGroupedAllocation: (x) => x.ItemID, - newPlanBulkWithProration: (x) => x.ItemID, - newPlanGroupedWithProratedMinimum: (x) => x.ItemID, - newPlanGroupedWithMeteredMinimum: (x) => x.ItemID, - groupedWithMinMaxThresholds: (x) => x.ItemID, - newPlanMatrixWithDisplayName: (x) => x.ItemID, - newPlanGroupedTieredPackage: (x) => x.ItemID, - newPlanMaxGroupTieredPackage: (x) => x.ItemID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ItemID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ItemID, - newPlanCumulativeGroupedBulk: (x) => x.ItemID, - cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, - newPlanMinimumComposite: (x) => x.ItemID, - percent: (x) => x.ItemID, - eventOutput: (x) => x.ItemID - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); } + init { this._rawData.Set("currency", value); } } - public string Name + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { get { - return Match( - newPlanUnit: (x) => x.Name, - newPlanTiered: (x) => x.Name, - newPlanBulk: (x) => x.Name, - bulkWithFilters: (x) => x.Name, - newPlanPackage: (x) => x.Name, - newPlanMatrix: (x) => x.Name, - newPlanThresholdTotalAmount: (x) => x.Name, - newPlanTieredPackage: (x) => x.Name, - newPlanTieredWithMinimum: (x) => x.Name, - newPlanGroupedTiered: (x) => x.Name, - newPlanTieredPackageWithMinimum: (x) => x.Name, - newPlanPackageWithAllocation: (x) => x.Name, - newPlanUnitWithPercent: (x) => x.Name, - newPlanMatrixWithAllocation: (x) => x.Name, - tieredWithProration: (x) => x.Name, - newPlanUnitWithProration: (x) => x.Name, - newPlanGroupedAllocation: (x) => x.Name, - newPlanBulkWithProration: (x) => x.Name, - newPlanGroupedWithProratedMinimum: (x) => x.Name, - newPlanGroupedWithMeteredMinimum: (x) => x.Name, - groupedWithMinMaxThresholds: (x) => x.Name, - newPlanMatrixWithDisplayName: (x) => x.Name, - newPlanGroupedTieredPackage: (x) => x.Name, - newPlanMaxGroupTieredPackage: (x) => x.Name, - newPlanScalableMatrixWithUnitPricing: (x) => x.Name, - newPlanScalableMatrixWithTieredPricing: (x) => x.Name, - newPlanCumulativeGroupedBulk: (x) => x.Name, - cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, - newPlanMinimumComposite: (x) => x.Name, - percent: (x) => x.Name, - eventOutput: (x) => x.Name + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" ); } + init { this._rawData.Set("dimensional_price_configuration", value); } } - public string? BillableMetricID + /// + /// An alias for the price. + /// + public string? ExternalPriceID { get { - return Match( - newPlanUnit: (x) => x.BillableMetricID, - newPlanTiered: (x) => x.BillableMetricID, - newPlanBulk: (x) => x.BillableMetricID, - bulkWithFilters: (x) => x.BillableMetricID, - newPlanPackage: (x) => x.BillableMetricID, - newPlanMatrix: (x) => x.BillableMetricID, - newPlanThresholdTotalAmount: (x) => x.BillableMetricID, - newPlanTieredPackage: (x) => x.BillableMetricID, - newPlanTieredWithMinimum: (x) => x.BillableMetricID, - newPlanGroupedTiered: (x) => x.BillableMetricID, - newPlanTieredPackageWithMinimum: (x) => x.BillableMetricID, - newPlanPackageWithAllocation: (x) => x.BillableMetricID, - newPlanUnitWithPercent: (x) => x.BillableMetricID, - newPlanMatrixWithAllocation: (x) => x.BillableMetricID, - tieredWithProration: (x) => x.BillableMetricID, - newPlanUnitWithProration: (x) => x.BillableMetricID, - newPlanGroupedAllocation: (x) => x.BillableMetricID, - newPlanBulkWithProration: (x) => x.BillableMetricID, - newPlanGroupedWithProratedMinimum: (x) => x.BillableMetricID, - newPlanGroupedWithMeteredMinimum: (x) => x.BillableMetricID, - groupedWithMinMaxThresholds: (x) => x.BillableMetricID, - newPlanMatrixWithDisplayName: (x) => x.BillableMetricID, - newPlanGroupedTieredPackage: (x) => x.BillableMetricID, - newPlanMaxGroupTieredPackage: (x) => x.BillableMetricID, - newPlanScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, - newPlanScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, - newPlanCumulativeGroupedBulk: (x) => x.BillableMetricID, - cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, - newPlanMinimumComposite: (x) => x.BillableMetricID, - percent: (x) => x.BillableMetricID, - eventOutput: (x) => x.BillableMetricID - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); } + init { this._rawData.Set("external_price_id", value); } } - public bool? BilledInAdvance + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity { get { - return Match( - newPlanUnit: (x) => x.BilledInAdvance, - newPlanTiered: (x) => x.BilledInAdvance, - newPlanBulk: (x) => x.BilledInAdvance, - bulkWithFilters: (x) => x.BilledInAdvance, - newPlanPackage: (x) => x.BilledInAdvance, - newPlanMatrix: (x) => x.BilledInAdvance, - newPlanThresholdTotalAmount: (x) => x.BilledInAdvance, - newPlanTieredPackage: (x) => x.BilledInAdvance, - newPlanTieredWithMinimum: (x) => x.BilledInAdvance, - newPlanGroupedTiered: (x) => x.BilledInAdvance, - newPlanTieredPackageWithMinimum: (x) => x.BilledInAdvance, - newPlanPackageWithAllocation: (x) => x.BilledInAdvance, - newPlanUnitWithPercent: (x) => x.BilledInAdvance, - newPlanMatrixWithAllocation: (x) => x.BilledInAdvance, - tieredWithProration: (x) => x.BilledInAdvance, - newPlanUnitWithProration: (x) => x.BilledInAdvance, - newPlanGroupedAllocation: (x) => x.BilledInAdvance, - newPlanBulkWithProration: (x) => x.BilledInAdvance, - newPlanGroupedWithProratedMinimum: (x) => x.BilledInAdvance, - newPlanGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, - groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, - newPlanMatrixWithDisplayName: (x) => x.BilledInAdvance, - newPlanGroupedTieredPackage: (x) => x.BilledInAdvance, - newPlanMaxGroupTieredPackage: (x) => x.BilledInAdvance, - newPlanScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, - newPlanScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, - newPlanCumulativeGroupedBulk: (x) => x.BilledInAdvance, - cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, - newPlanMinimumComposite: (x) => x.BilledInAdvance, - percent: (x) => x.BilledInAdvance, - eventOutput: (x) => x.BilledInAdvance - ); + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); } + init { this._rawData.Set("fixed_price_quantity", value); } } - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey { 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 - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); } + init { this._rawData.Set("invoice_grouping_key", value); } } - public double? ConversionRate + /// + /// 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 { - 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 + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" ); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - public string? Currency + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { 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 - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); } + init { this._rawData.Set("license_type_id", value); } } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + /// User-specified key/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 { - 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 - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); } - } - - public string? ExternalPriceID - { - get + init { - 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 + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) ); } } - public double? FixedPriceQuantity + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID { 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 - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); } + init { this._rawData.Set("reference_id", value); } } - public string? InvoiceGroupingKey + /// + public override void Validate() { - get + this.Cadence.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) { - 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 - ); + item.Validate(); } - } - - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_with_minimum") + ) + ) { - 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 - ); + 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 string? ReferenceID + public TieredWithMinimum() { - 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 - ); - } + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); } - public ReplacePricePrice(NewPlanUnitPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimum(TieredWithMinimum tieredWithMinimum) + : base(tieredWithMinimum) { } +#pragma warning restore CS8618 - public ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) + public TieredWithMinimum(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); } - public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimum(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public ReplacePricePrice(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) + /// + public static TieredWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public ReplacePricePrice(NewPlanPackagePrice value, JsonElement? element = null) +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 + ) { - this.Value = value; - this._element = element; + 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 ReplacePricePrice(NewPlanMatrixPrice value, JsonElement? element = null) + public override void Write( + Utf8JsonWriter writer, + TieredWithMinimumCadence value, + JsonSerializerOptions options + ) { - this.Value = value; - this._element = element; + 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 + ); } +} - public ReplacePricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) +[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 { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } } - public ReplacePricePrice(NewPlanTieredPackagePrice value, JsonElement? element = null) + /// + /// The currency of the license allocation. + /// + public required string Currency { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } } - public ReplacePricePrice(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } } - public ReplacePricePrice(NewPlanGroupedTieredPrice value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public ReplacePricePrice( - NewPlanTieredPackageWithMinimumPrice value, - JsonElement? element = null + public TieredWithMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumLicenseAllocation( + TieredWithMinimumLicenseAllocation tieredWithMinimumLicenseAllocation ) - { - this.Value = value; - this._element = element; - } + : base(tieredWithMinimumLicenseAllocation) { } +#pragma warning restore CS8618 - public ReplacePricePrice(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + public TieredWithMinimumLicenseAllocation(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public ReplacePricePrice(NewPlanUnitWithPercentPrice value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimumLicenseAllocation(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public ReplacePricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) + /// + public static TieredWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public ReplacePricePrice( - ReplacePricePriceTieredWithProration value, - JsonElement? element = null - ) +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 { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } } - public ReplacePricePrice(NewPlanUnitWithProrationPrice value, JsonElement? element = null) + /// + /// If true, tiers with an accrued amount of 0 will not be included in the rating. + /// + public bool? HideZeroAmountTiers { - this.Value = value; - this._element = element; + 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); + } } - public ReplacePricePrice(NewPlanGroupedAllocationPrice value, JsonElement? element = null) + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("prorate", value); + } } - public ReplacePricePrice(NewPlanBulkWithProrationPrice value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + foreach (var item in this.Tiers) + { + item.Validate(); + } + _ = this.HideZeroAmountTiers; + _ = this.Prorate; } - public ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value, - JsonElement? element = null - ) + public TieredWithMinimumConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumConfig(TieredWithMinimumConfig tieredWithMinimumConfig) + : base(tieredWithMinimumConfig) { } +#pragma warning restore CS8618 + + public TieredWithMinimumConfig(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value, - JsonElement? element = null - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimumConfig(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null + /// + public static TieredWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - public ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) + [SetsRequiredMembers] + public TieredWithMinimumConfig(IReadOnlyList tiers) + : this() { - this.Value = value; - this._element = element; + this.Tiers = tiers; } +} - public ReplacePricePrice(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +class TieredWithMinimumConfigFromRaw : IFromRawJson +{ + /// + public TieredWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithMinimumConfig.FromRawUnchecked(rawData); +} - public ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) +/// +/// Configuration for a single tier +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredWithMinimumConfigTier : JsonModel +{ + public required string MinimumAmount { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", value); } } - public ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) + public required string TierLowerBound { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } } - public ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null - ) + /// + /// Per unit amount + /// + public required string UnitAmount { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } } - public ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.MinimumAmount; + _ = this.TierLowerBound; + _ = this.UnitAmount; } - public ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null - ) + public TieredWithMinimumConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumConfigTier(TieredWithMinimumConfigTier tieredWithMinimumConfigTier) + : base(tieredWithMinimumConfigTier) { } +#pragma warning restore CS8618 + + public TieredWithMinimumConfigTier(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public ReplacePricePrice(ReplacePricePriceMinimum value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimumConfigTier(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public ReplacePricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) + /// + public static TieredWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) +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 ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) + public TieredWithMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public ReplacePricePrice(JsonElement 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 . + /// 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 `SharedUnitConversionRateConfig` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) { - value = this.Value as NewPlanUnitPrice; + 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.TryPickNewPlanTiered(out var value)) { - /// // `value` is of type `NewPlanTieredPrice` + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) { - value = this.Value as NewPlanTieredPrice; + value = this.Value as SharedTieredConversionRateConfig; 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.TryPickNewPlanBulk(out var value)) { - /// // `value` is of type `NewPlanBulkPrice` - /// Console.WriteLine(value); - /// } + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); /// /// /// - public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) + public void Switch( + System::Action unit, + System::Action tiered + ) { - value = this.Value as NewPlanBulkPrice; - return value != null; + 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" + ); + } } /// - /// 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.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `ReplacePricePriceBulkWithFilters` - /// Console.WriteLine(value); - /// } + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value + public T Match( + System::Func unit, + System::Func tiered ) { - value = this.Value as ReplacePricePriceBulkWithFilters; - return value != null; + 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); + /// - /// 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.TryPickNewPlanPackage(out var value)) { - /// // `value` is of type `NewPlanPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// + /// Thrown when the instance does not pass validation. + /// /// - public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) + public override void Validate() { - value = this.Value as NewPlanPackagePrice; - return value != null; + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of TieredWithMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.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.TryPickNewPlanMatrix(out var value)) { - /// // `value` is of type `NewPlanMatrixPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) + public virtual bool Equals(TieredWithMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() { - value = this.Value as NewPlanMatrixPrice; - 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.TryPickNewPlanThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewPlanThresholdTotalAmountPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanThresholdTotalAmount( - [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value - ) + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() { - value = this.Value as NewPlanThresholdTotalAmountPrice; - return value != null; + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; } +} - /// - /// Returns true and sets the 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 +sealed class TieredWithMinimumConversionRateConfigConverter + : JsonConverter +{ + public override TieredWithMinimumConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - value = this.Value as NewPlanTieredPackagePrice; - return value != null; + 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); + } + } } - /// - /// Returns true and sets the 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 + public override void Write( + Utf8JsonWriter writer, + TieredWithMinimumConversionRateConfig value, + JsonSerializerOptions options ) { - value = this.Value as NewPlanTieredWithMinimumPrice; - return value != null; + JsonSerializer.Serialize(writer, value.Json, options); } +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedTiered : JsonModel +{ /// - /// Returns true and sets the 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); - /// } - /// - /// + /// The cadence to bill for this price on. /// - public bool TryPickNewPlanGroupedTiered( - [NotNullWhen(true)] out NewPlanGroupedTieredPrice? value - ) + public required ApiEnum Cadence { - value = this.Value as NewPlanGroupedTieredPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>("cadence"); + } + init { this._rawData.Set("cadence", 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.TryPickNewPlanTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewPlanTieredPackageWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// Configuration for grouped_tiered pricing /// - public bool TryPickNewPlanTieredPackageWithMinimum( - [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? value - ) + public required GroupedTieredConfig GroupedTieredConfig { - value = this.Value as NewPlanTieredPackageWithMinimumPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouped_tiered_config"); + } + init { this._rawData.Set("grouped_tiered_config", 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.TryPickNewPlanPackageWithAllocation(out var value)) { - /// // `value` is of type `NewPlanPackageWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the item the price will be associated with. /// - public bool TryPickNewPlanPackageWithAllocation( - [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value - ) + public required string ItemID { - value = this.Value as NewPlanPackageWithAllocationPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", 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.TryPickNewPlanUnitWithPercent(out var value)) { - /// // `value` is of type `NewPlanUnitWithPercentPrice` - /// Console.WriteLine(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 bool TryPickNewPlanUnitWithPercent( - [NotNullWhen(true)] out NewPlanUnitWithPercentPrice? value - ) + public required IReadOnlyList LicenseAllocations { - value = this.Value as NewPlanUnitWithPercentPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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.TryPickNewPlanMatrixWithAllocation(out var value)) { - /// // `value` is of type `NewPlanMatrixWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The pricing model type /// - public bool TryPickNewPlanMatrixWithAllocation( - [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value - ) + public JsonElement ModelType { - value = this.Value as NewPlanMatrixWithAllocationPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", 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.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `ReplacePricePriceTieredWithProration` - /// Console.WriteLine(value); - /// } - /// - /// + /// The name of the price. /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value - ) + public required string Name { - value = this.Value as ReplacePricePriceTieredWithProration; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", 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.TryPickNewPlanUnitWithProration(out var value)) { - /// // `value` is of type `NewPlanUnitWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. /// - public bool TryPickNewPlanUnitWithProration( - [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value - ) + public string? BillableMetricID { - value = this.Value as NewPlanUnitWithProrationPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", 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.TryPickNewPlanGroupedAllocation(out var value)) { - /// // `value` is of type `NewPlanGroupedAllocationPrice` - /// Console.WriteLine(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 TryPickNewPlanGroupedAllocation( - [NotNullWhen(true)] out NewPlanGroupedAllocationPrice? value - ) + public bool? BilledInAdvance { - value = this.Value as NewPlanGroupedAllocationPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", 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.TryPickNewPlanBulkWithProration(out var value)) { - /// // `value` is of type `NewPlanBulkWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. /// - public bool TryPickNewPlanBulkWithProration( - [NotNullWhen(true)] out NewPlanBulkWithProrationPrice? value - ) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - value = this.Value as NewPlanBulkWithProrationPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", 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.TryPickNewPlanGroupedWithProratedMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithProratedMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The per unit conversion rate of the price currency to the invoicing currency. /// - public bool TryPickNewPlanGroupedWithProratedMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithProratedMinimumPrice? value - ) + public double? ConversionRate { - value = this.Value as NewPlanGroupedWithProratedMinimumPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", 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.TryPickNewPlanGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithMeteredMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The configuration for the rate of the price currency to the invoicing currency. /// - public bool TryPickNewPlanGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value - ) + public GroupedTieredConversionRateConfig? ConversionRateConfig { - value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `ReplacePricePriceGroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value - ) + public string? Currency { - value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// For dimensional price: specifies a price group and dimension values /// - public bool TryPickNewPlanMatrixWithDisplayName( - [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value - ) + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - value = this.Value as NewPlanMatrixWithDisplayNamePrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", 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.TryPickNewPlanGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// An alias for the price. /// - public bool TryPickNewPlanGroupedTieredPackage( - [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value - ) + public string? ExternalPriceID { - value = this.Value as NewPlanGroupedTieredPackagePrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", 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.TryPickNewPlanMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. /// - public bool TryPickNewPlanMaxGroupTieredPackage( - [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? value - ) + public double? FixedPriceQuantity { - value = this.Value as NewPlanMaxGroupTieredPackagePrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", 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.TryPickNewPlanScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithUnitPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The property used to group this price on an invoice /// - public bool TryPickNewPlanScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithUnitPricingPrice? value - ) + public string? InvoiceGroupingKey { - value = this.Value as NewPlanScalableMatrixWithUnitPricingPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", 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.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. /// - public bool TryPickNewPlanScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value - ) + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", 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.TryPickNewPlanCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The ID of the license type to associate with this price. /// - public bool TryPickNewPlanCumulativeGroupedBulk( - [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value - ) + public string? LicenseTypeID { - value = this.Value as NewPlanCumulativeGroupedBulkPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", 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); - /// } - /// - /// + /// User-specified key/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 bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out ReplacePricePriceCumulativeGroupedAllocation? value - ) + public IReadOnlyDictionary? Metadata { - value = this.Value as ReplacePricePriceCumulativeGroupedAllocation; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(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); - /// } - /// - /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. /// - public bool TryPickMinimum([NotNullWhen(true)] out ReplacePricePriceMinimum? value) + public string? ReferenceID { - value = this.Value as ReplacePricePriceMinimum; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); + } + init { this._rawData.Set("reference_id", 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.TryPickNewPlanMinimumComposite(out var value)) { - /// // `value` is of type `NewPlanMinimumCompositePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMinimumComposite( - [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value - ) + /// + public override void Validate() { - value = this.Value as NewPlanMinimumCompositePrice; - return value != null; + 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; } - /// - /// Returns true and sets the 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) + public GroupedTiered() { - value = this.Value as ReplacePricePricePercent; - return value != null; + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered"); } - /// - /// Returns true and sets the 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) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTiered(GroupedTiered groupedTiered) + : base(groupedTiered) { } +#pragma warning restore CS8618 + + public GroupedTiered(IReadOnlyDictionary rawData) { - value = this.Value as ReplacePricePriceEventOutput; - return value != null; + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered"); } - /// - /// 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) => {...} +#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 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 + System::Action unit, + System::Action tiered ) { 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); + case SharedUnitConversionRateConfig value: + unit(value); break; - case ReplacePricePriceEventOutput value: - eventOutput(value); + case SharedTieredConversionRateConfig value: + tiered(value); break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" + "Data did not match any variant of GroupedTieredConversionRateConfig" ); } } @@ -11884,227 +12583,35 @@ public void Switch( /// /// /// 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) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig 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 + System::Func unit, + System::Func tiered ) { 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), + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" + "Data did not match any variant of GroupedTieredConversionRateConfig" ), }; } - 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 + public static implicit operator GroupedTieredConversionRateConfig( + SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value) => - new(value); - - public static implicit operator ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value + public static implicit operator GroupedTieredConversionRateConfig( + SharedTieredConversionRateConfig 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). @@ -12120,51 +12627,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" + "Data did not match any variant of GroupedTieredConversionRateConfig" ); } - 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() - ); + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ReplacePricePrice? 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() { @@ -12172,35 +12644,49 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplacePricePriceConverter : JsonConverter +sealed class GroupedTieredConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePrice? Read( + public override GroupedTieredConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; + string? conversionRateType; try { - modelType = element.GetProperty("model_type").GetString(); + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); } catch { - modelType = null; + conversionRateType = null; } - switch (modelType) + switch (conversionRateType) { case "unit": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -12222,7 +12708,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -12240,1609 +12726,66044 @@ JsonSerializerOptions options return new(element); } - case "bulk": + default: { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); + return new GroupedTieredConversionRateConfig(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 - } + public override void Write( + Utf8JsonWriter writer, + GroupedTieredConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} - 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 - } +[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); } + } - 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 - } + /// + /// 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); } + } - 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 - } + /// + /// 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) + ); + } + } - 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 pricing model type + /// + public JsonElement ModelType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } + } - 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 - } + /// + /// The name of the price. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } - 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 + /// + /// 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); - } - 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); + } + default: + { + return new ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceEventOutputConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +/// +/// 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 + { + 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 ReplacePricePrice(NewPlanUnitPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) + { + 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; + } - return new(element); - } - case "unit_with_percent": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePrice( + ReplacePricePriceTieredWithProration value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - 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 ReplacePricePrice(NewPlanUnitWithProrationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "tiered_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePrice(NewPlanGroupedAllocationPrice 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 ReplacePricePrice(NewPlanBulkWithProrationPrice 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 ReplacePricePrice( + NewPlanGroupedWithProratedMinimumPrice value, + JsonElement? element = null + ) + { + this.Value = value; + 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 - } + public ReplacePricePrice( + NewPlanGroupedWithMeteredMinimumPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - 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 - } + public ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - 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 - } + public ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePrice(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - 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 ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - 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 ReplacePricePrice( + NewPlanScalableMatrixWithUnitPricingPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "max_group_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePrice( + NewPlanScalableMatrixWithTieredPricingPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - 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 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(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; + } + + /// + /// Returns true and sets the 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 `ReplacePricePriceBulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters( + [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value + ) + { + value = this.Value as ReplacePricePriceBulkWithFilters; + return value != null; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - 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 - } + /// + /// Returns true and sets the 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; + } - return new(element); - } - default: - { - return new ReplacePricePrice(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.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; } - public override void Write( - Utf8JsonWriter writer, - ReplacePricePrice? value, - JsonSerializerOptions options + /// + /// Returns true and sets the 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 ) { - JsonSerializer.Serialize(writer, value?.Json, options); + value = this.Value as NewPlanUnitWithPercentPrice; + return value != null; } -} -[JsonConverter( - typeof(JsonModelConverter< - ReplacePricePriceBulkWithFilters, - ReplacePricePriceBulkWithFiltersFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFilters : JsonModel -{ /// - /// Configuration for bulk_with_filters pricing + /// Returns true and sets the 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 required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig + public bool TryPickNewPlanMatrixWithAllocation( + [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); - } - init { this._rawData.Set("bulk_with_filters_config", value); } + value = this.Value as NewPlanMatrixWithAllocationPrice; + return value != null; } /// - /// The cadence to bill for this price on. + /// Returns true and sets the 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 required ApiEnum Cadence + public bool TryPickTieredWithProration( + [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); - } - init { this._rawData.Set("cadence", value); } + value = this.Value as ReplacePricePriceTieredWithProration; + return value != null; } /// - /// The id of the item the price will be associated with. + /// Returns true and sets the 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 required string ItemID + public bool TryPickNewPlanUnitWithProration( + [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } + value = this.Value as NewPlanUnitWithProrationPrice; + return value != null; } /// - /// The pricing model type + /// Returns true and sets the 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 JsonElement ModelType + public bool TryPickNewPlanGroupedAllocation( + [NotNullWhen(true)] out NewPlanGroupedAllocationPrice? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", 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; } /// - /// The name of the price. + /// Returns true and sets the 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 required string Name + public bool TryPickNewPlanGroupedWithMeteredMinimum( + [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } + value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; + return value != null; } /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// Returns true and sets the 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 string? BillableMetricID + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } + value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; + return value != null; } /// - /// 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. + /// Returns true and sets the 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? BilledInAdvance + public bool TryPickNewPlanMatrixWithDisplayName( + [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } + value = this.Value as NewPlanMatrixWithDisplayNamePrice; + return value != null; } /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. + /// Returns true and sets the 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 NewBillingCycleConfiguration? BillingCycleConfiguration + public bool TryPickNewPlanGroupedTieredPackage( + [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } + value = this.Value as NewPlanGroupedTieredPackagePrice; + return value != null; } /// - /// The per unit conversion rate of the price currency to the invoicing 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.TryPickNewPlanMaxGroupTieredPackage(out var value)) { + /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// /// - public double? ConversionRate + public bool TryPickNewPlanMaxGroupTieredPackage( + [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } + value = this.Value as NewPlanMaxGroupTieredPackagePrice; + return value != null; } /// - /// The configuration for the rate of the price currency to the invoicing 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.TryPickNewPlanScalableMatrixWithUnitPricing(out var value)) { + /// // `value` is of type `NewPlanScalableMatrixWithUnitPricingPrice` + /// Console.WriteLine(value); + /// } + /// + /// /// - public ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig + public bool TryPickNewPlanScalableMatrixWithUnitPricing( + [NotNullWhen(true)] out NewPlanScalableMatrixWithUnitPricingPrice? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } + value = this.Value as NewPlanScalableMatrixWithUnitPricingPrice; + return value != null; } /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. + /// Returns true and sets the 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 string? Currency + public bool TryPickNewPlanScalableMatrixWithTieredPricing( + [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); - } - init { this._rawData.Set("currency", value); } + value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; + return value != null; } /// - /// For dimensional price: specifies a price group and dimension values + /// Returns true and sets the 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 NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + public bool TryPickNewPlanCumulativeGroupedBulk( + [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } + value = this.Value as NewPlanCumulativeGroupedBulkPrice; + return value != null; } /// - /// An alias for the price. + /// Returns true and sets the 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 string? ExternalPriceID + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] out ReplacePricePriceCumulativeGroupedAllocation? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } + value = this.Value as ReplacePricePriceCumulativeGroupedAllocation; + return value != null; } /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// Returns true and sets the 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 double? FixedPriceQuantity + public bool TryPickNewPlanMinimumComposite( + [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } + value = this.Value as NewPlanMinimumCompositePrice; + return value != null; } /// - /// The property used to group this price on an invoice + /// Returns true and sets the 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 string? InvoiceGroupingKey + public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } + value = this.Value as ReplacePricePricePercent; + return value != null; } /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. + /// Returns true and sets the 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 NewBillingCycleConfiguration? InvoicingCycleConfiguration + public bool TryPickEventOutput([NotNullWhen(true)] out ReplacePricePriceEventOutput? value) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } + value = this.Value as ReplacePricePriceEventOutput; + return value != null; } /// - /// User-specified key/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`. + /// 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) => {...}, + /// (NewPlanMinimumCompositePrice value) => {...}, + /// (ReplacePricePricePercent value) => {...}, + /// (ReplacePricePriceEventOutput value) => {...} + /// ); + /// + /// /// - public IReadOnlyDictionary? Metadata + 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 + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init + switch (this.Value) { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(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" + ); } } /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. + /// 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) => {...}, + /// (NewPlanMinimumCompositePrice value) => {...}, + /// (ReplacePricePricePercent value) => {...}, + /// (ReplacePricePriceEventOutput value) => {...} + /// ); + /// + /// /// - public string? ReferenceID + 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 + ) { - get + return this.Value switch { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); - } - init { this._rawData.Set("reference_id", value); } + NewPlanUnitPrice value => newPlanUnit(value), + NewPlanTieredPrice value => newPlanTiered(value), + NewPlanBulkPrice value => newPlanBulk(value), + ReplacePricePriceBulkWithFilters value => bulkWithFilters(value), + NewPlanPackagePrice value => newPlanPackage(value), + NewPlanMatrixPrice value => newPlanMatrix(value), + NewPlanThresholdTotalAmountPrice value => newPlanThresholdTotalAmount(value), + NewPlanTieredPackagePrice value => newPlanTieredPackage(value), + NewPlanTieredWithMinimumPrice value => newPlanTieredWithMinimum(value), + NewPlanGroupedTieredPrice value => newPlanGroupedTiered(value), + NewPlanTieredPackageWithMinimumPrice value => newPlanTieredPackageWithMinimum(value), + NewPlanPackageWithAllocationPrice value => newPlanPackageWithAllocation(value), + NewPlanUnitWithPercentPrice value => newPlanUnitWithPercent(value), + NewPlanMatrixWithAllocationPrice value => newPlanMatrixWithAllocation(value), + ReplacePricePriceTieredWithProration value => tieredWithProration(value), + NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), + NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), + NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), + NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( + value + ), + NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), + ReplacePricePriceGroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds( + value + ), + NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), + NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), + NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), + NewPlanScalableMatrixWithUnitPricingPrice value => newPlanScalableMatrixWithUnitPricing( + value + ), + NewPlanScalableMatrixWithTieredPricingPrice value => + newPlanScalableMatrixWithTieredPricing(value), + NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), + ReplacePricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation( + value + ), + NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), + ReplacePricePricePercent value => percent(value), + ReplacePricePriceEventOutput value => eventOutput(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePrice" + ), + }; } - /// - public 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 static implicit operator ReplacePricePrice(NewPlanUnitPrice value) => new(value); - public ReplacePricePriceBulkWithFilters() - { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } + public static implicit operator ReplacePricePrice(NewPlanTieredPrice value) => new(value); - public ReplacePricePriceBulkWithFilters( - ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters - ) - : base(replacePricePriceBulkWithFilters) { } + public static implicit operator ReplacePricePrice(NewPlanBulkPrice value) => new(value); - public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); + public static implicit operator ReplacePricePrice(ReplacePricePriceBulkWithFilters value) => + new(value); - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } + public static implicit operator ReplacePricePrice(NewPlanPackagePrice value) => new(value); -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + public static implicit operator ReplacePricePrice(NewPlanMatrixPrice value) => new(value); - /// - public static ReplacePricePriceBulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} + public static implicit operator ReplacePricePrice(NewPlanThresholdTotalAmountPrice value) => + new(value); -class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson -{ - /// - public ReplacePricePriceBulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); -} + public static implicit operator ReplacePricePrice(NewPlanTieredPackagePrice value) => + new(value); -/// -/// 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)); - } - } + public static implicit operator ReplacePricePrice(NewPlanTieredWithMinimumPrice value) => + new(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 static implicit operator ReplacePricePrice(NewPlanGroupedTieredPrice value) => + new(value); - /// - public override void Validate() - { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) - { - item.Validate(); - } - } + public static implicit operator ReplacePricePrice(NewPlanTieredPackageWithMinimumPrice value) => + new(value); - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } + public static implicit operator ReplacePricePrice(NewPlanPackageWithAllocationPrice value) => + new(value); - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } + public static implicit operator ReplacePricePrice(NewPlanUnitWithPercentPrice value) => + new(value); - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } + public static implicit operator ReplacePricePrice(NewPlanMatrixWithAllocationPrice value) => + new(value); -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + public static implicit operator ReplacePricePrice(ReplacePricePriceTieredWithProration value) => + new(value); - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} + public static implicit operator ReplacePricePrice(NewPlanUnitWithProrationPrice value) => + new(value); -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - : IFromRawJson -{ - /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); -} + public static implicit operator ReplacePricePrice(NewPlanGroupedAllocationPrice value) => + new(value); -/// -/// 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); } - } + public static implicit operator ReplacePricePrice(NewPlanBulkWithProrationPrice value) => + new(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 static implicit operator ReplacePricePrice( + NewPlanGroupedWithProratedMinimumPrice value + ) => new(value); - /// - public override void Validate() - { - _ = this.PropertyKey; - _ = this.PropertyValue; - } + public static implicit operator ReplacePricePrice( + NewPlanGroupedWithMeteredMinimumPrice value + ) => new(value); - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } + public static implicit operator ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds value + ) => new(value); - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } + public static implicit operator ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value) => + new(value); - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } + public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPackagePrice value) => + new(value); -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + public static implicit operator ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value) => + new(value); - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} + public static implicit operator ReplacePricePrice( + NewPlanScalableMatrixWithUnitPricingPrice value + ) => new(value); -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - : IFromRawJson -{ - /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); -} + public static implicit operator ReplacePricePrice( + NewPlanScalableMatrixWithTieredPricingPrice value + ) => new(value); -/// -/// 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); } - } + 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); /// - /// The lower bound for this tier + /// 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 string? TierLowerBound + public override void Validate() { - get + if (this.Value == null) { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePrice" + ); } - init { this._rawData.Set("tier_lower_bound", value); } - } - - /// - public override void Validate() - { - _ = this.UnitAmount; - _ = this.TierLowerBound; + 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } + public virtual bool Equals(ReplacePricePrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - FrozenDictionary rawData - ) + public override int GetHashCode() { - this._rawData = new(rawData); + return 0; } -#pragma warning restore CS8618 - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - [SetsRequiredMembers] - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) - : this() + int VariantIndex() { - this.UnitAmount = unitAmount; + 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, + }; } } -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 +sealed class ReplacePricePriceConverter : JsonConverter { - public override ReplacePricePriceBulkWithFiltersCadence Read( + public override ReplacePricePrice? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { - return JsonSerializer.Deserialize(ref reader, options) switch + var element = JsonSerializer.Deserialize(ref reader, options); + string? modelType; + try { - "annual" => ReplacePricePriceBulkWithFiltersCadence.Annual, - "semi_annual" => ReplacePricePriceBulkWithFiltersCadence.SemiAnnual, - "monthly" => ReplacePricePriceBulkWithFiltersCadence.Monthly, - "quarterly" => ReplacePricePriceBulkWithFiltersCadence.Quarterly, - "one_time" => ReplacePricePriceBulkWithFiltersCadence.OneTime, - "custom" => ReplacePricePriceBulkWithFiltersCadence.Custom, - _ => (ReplacePricePriceBulkWithFiltersCadence)(-1), - }; - } + modelType = element.GetProperty("model_type").GetString(); + } + catch + { + modelType = null; + } - public override void Write( - Utf8JsonWriter writer, - ReplacePricePriceBulkWithFiltersCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch + switch (modelType) + { + case "unit": { - 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 "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 + } - JsonElement? _element = null; + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } + 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 ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + 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 ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + 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 + } - public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) - { - this._element = element; - } + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) - { - value = this.Value as SharedUnitConversionRateConfig; - return value != null; - } + return new(element); + } + case "grouped_with_prorated_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) - { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; - } + return new(element); + } + case "grouped_with_metered_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.Value) - { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - } + return new(element); + } + case "grouped_with_min_max_thresholds": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) - { - return this.Value switch - { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" - ), - }; - } + return new(element); + } + case "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + return new(element); + } + case "max_group_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } + return new(element); + } + case "scalable_matrix_with_unit_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + return new(element); + } + case "scalable_matrix_with_tiered_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override int GetHashCode() - { - return 0; - } + return new(element); + } + case "cumulative_grouped_bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + return new(element); + } + case "cumulative_grouped_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter - : JsonConverter -{ - public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } + return new(element); + } + case "minimum_composite": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - switch (conversionRateType) - { - case "unit": + return new(element); + } + case "percent": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -13860,11 +78781,11 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "event_output": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -13884,39 +78805,54 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); + return new ReplacePricePrice(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceBulkWithFiltersConversionRateConfig value, + ReplacePricePrice? value, JsonSerializerOptions options ) { - JsonSerializer.Serialize(writer, value.Json, options); + JsonSerializer.Serialize(writer, value?.Json, options); } } [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceTieredWithProration, - ReplacePricePriceTieredWithProrationFromRaw + ReplacePricePriceBulkWithFilters, + ReplacePricePriceBulkWithFiltersFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProration : JsonModel +public sealed record class ReplacePricePriceBulkWithFilters : JsonModel { + /// + /// Configuration for bulk_with_filters pricing + /// + public required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_filters_config" + ); + } + init { this._rawData.Set("bulk_with_filters_config", value); } + } + /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -13961,21 +78897,6 @@ public required string Name init { this._rawData.Set("name", value); } } - /// - /// Configuration for tiered_with_proration pricing - /// - public required ReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "tiered_with_proration_config" - ); - } - init { this._rawData.Set("tiered_with_proration_config", value); } - } - /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -14035,12 +78956,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" ); } @@ -14131,6 +79052,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 @@ -14169,19 +79103,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(); @@ -14193,37 +79127,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceTieredWithProration() + public ReplacePricePriceBulkWithFilters() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public ReplacePricePriceTieredWithProration( - ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFilters( + ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters ) - : base(replacePricePriceTieredWithProration) { } + : base(replacePricePriceBulkWithFilters) { } +#pragma warning restore CS8618 - public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) + public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProration(FrozenDictionary rawData) + ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceTieredWithProration FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFilters FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -14231,103 +79169,61 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceTieredWithProrationFromRaw - : IFromRawJson +class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson { /// - public ReplacePricePriceTieredWithProration FromRawUnchecked( + public ReplacePricePriceBulkWithFilters 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 - ); - } + ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); } /// -/// Configuration for tiered_with_proration pricing +/// Configuration for bulk_with_filters pricing /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceTieredWithProrationTieredWithProrationConfig, - ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel { /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration + /// Property filters to apply (all must match) /// - public required IReadOnlyList Tiers + public required IReadOnlyList Filters { get { this._rawData.Freeze(); return this._rawData.GetNotNullStruct< - ImmutableArray + 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 + ImmutableArray >("tiers", ImmutableArray.ToImmutableArray(value)); } } @@ -14335,20 +79231,27 @@ public required IReadOnlyList public override void Validate() { + foreach (var item in this.Filters) + { + item.Validate(); + } foreach (var item in this.Tiers) { item.Validate(); } } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( IReadOnlyDictionary rawData ) { @@ -14357,7 +79260,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( FrozenDictionary rawData ) { @@ -14365,86 +79268,168 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} + +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single property filter +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel +{ + /// + /// Event property key to filter on + /// + public required string PropertyKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_key"); + } + init { this._rawData.Set("property_key", value); } + } + /// + /// Event property value to match + /// + public required string PropertyValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_value"); + } + init { this._rawData.Set("property_value", value); } + } + + /// + public override void Validate() + { + _ = this.PropertyKey; + _ = this.PropertyValue; + } + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } + +#pragma warning disable CS8618 [SetsRequiredMembers] - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - IReadOnlyList tiers + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + ) + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + IReadOnlyDictionary rawData ) - : this() { - this.Tiers = tiers; + 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 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( IReadOnlyDictionary rawData ) { @@ -14453,7 +79438,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( FrozenDictionary rawData ) { @@ -14461,27 +79446,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 ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw - : IFromRawJson +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson { /// - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); } -[JsonConverter(typeof(ReplacePricePriceTieredWithProrationConversionRateConfigConverter))] -public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase +/// +/// 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 + ); + } +} + +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] +public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -14498,7 +79549,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -14507,7 +79558,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -14516,7 +79567,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -14598,7 +79649,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" ); } } @@ -14634,16 +79685,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -14662,16 +79713,16 @@ 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) - { - 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() { @@ -14679,13 +79730,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceTieredWithProrationConversionRateConfig? Read( + public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -14750,14 +79814,14 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); + return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceTieredWithProrationConversionRateConfig value, + ReplacePricePriceBulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -14767,42 +79831,27 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceGroupedWithMinMaxThresholds, - ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + ReplacePricePriceTieredWithProration, + ReplacePricePriceTieredWithProrationFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : JsonModel +public sealed record class ReplacePricePriceTieredWithProration : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } - /// - /// Configuration for grouped_with_min_max_thresholds pricing - /// - public required ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); - } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } - } - /// /// The id of the item the price will be associated with. /// @@ -14842,6 +79891,21 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for tiered_with_proration pricing + /// + public required ReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_proration_config" + ); + } + init { this._rawData.Set("tiered_with_proration_config", value); } + } + /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -14901,12 +79965,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" ); } @@ -14997,6 +80061,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 @@ -15036,18 +80113,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(); @@ -15059,39 +80136,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProration( + ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration ) - : base(replacePricePriceGroupedWithMinMaxThresholds) { } + : base(replacePricePriceTieredWithProration) { } +#pragma warning restore CS8618 - public ReplacePricePriceGroupedWithMinMaxThresholds( - IReadOnlyDictionary rawData - ) + public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) + ReplacePricePriceTieredWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15099,20 +80178,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationFromRaw + : IFromRawJson { /// - public ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => ReplacePricePriceTieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter))] -public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationCadenceConverter))] +public enum ReplacePricePriceTieredWithProrationCadence { Annual, SemiAnnual, @@ -15122,10 +80201,10 @@ public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence Custom, } -sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class ReplacePricePriceTieredWithProrationCadenceConverter + : JsonConverter { - public override ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( + public override ReplacePricePriceTieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15133,19 +80212,19 @@ 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, + ReplacePricePriceTieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -15153,12 +80232,12 @@ JsonSerializerOptions options writer, value switch { - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", + ReplacePricePriceTieredWithProrationCadence.Annual => "annual", + ReplacePricePriceTieredWithProrationCadence.SemiAnnual => "semi_annual", + ReplacePricePriceTieredWithProrationCadence.Monthly => "monthly", + ReplacePricePriceTieredWithProrationCadence.Quarterly => "quarterly", + ReplacePricePriceTieredWithProrationCadence.OneTime => "one_time", + ReplacePricePriceTieredWithProrationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -15169,86 +80248,156 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for tiered_with_proration pricing /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + ReplacePricePriceTieredWithProrationTieredWithProrationConfig, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - : JsonModel +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration /// - public required string GroupingKey + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); } - init { this._rawData.Set("grouping_key", value); } } - /// - /// The maximum amount to charge each group - /// - public required string MaximumCharge + /// + public override void Validate() { - get + foreach (var item in this.Tiers) { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + item.Validate(); } - init { this._rawData.Set("maximum_charge", value); } } + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig + ) + : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 + + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } +} + +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tiered with proration tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + >) +)] +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + : JsonModel +{ /// - /// The minimum amount to charge each group, regardless of usage + /// Inclusive tier starting value /// - public required string MinimumCharge + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// - /// The base price charged per group + /// Amount per unit /// - public required string PerUnitRate + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("per_unit_rate", value); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.TierLowerBound; + _ = this.UnitAmount; } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier ) - : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } + : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } +#pragma warning restore CS8618 - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData ) { @@ -15257,7 +80406,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -15265,8 +80414,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15274,20 +80423,18 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson { /// - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) => - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( - rawData - ); + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] -public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationConversionRateConfigConverter))] +public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -15304,7 +80451,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15313,7 +80460,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15322,7 +80469,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -15404,7 +80551,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ); } } @@ -15440,16 +80587,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -15468,18 +80615,16 @@ 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 - ) - { - 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() { @@ -15487,13 +80632,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override ReplacePricePriceTieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15558,16 +80716,14 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + ReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -15577,40 +80733,40 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceCumulativeGroupedAllocation, - ReplacePricePriceCumulativeGroupedAllocationFromRaw + ReplacePricePriceGroupedWithMinMaxThresholds, + ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonModel +public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// Configuration for cumulative_grouped_allocation pricing + /// Configuration for grouped_with_min_max_thresholds pricing /// - public required ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" + return this._rawData.GetNotNullClass( + "grouped_with_min_max_thresholds_config" ); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } } /// @@ -15711,12 +80867,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" ); } @@ -15807,6 +80963,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 @@ -15846,12 +81015,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") ) ) { @@ -15869,39 +81038,43 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceGroupedWithMinMaxThresholds( + ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds ) - : base(replacePricePriceCumulativeGroupedAllocation) { } + : base(replacePricePriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 - public ReplacePricePriceCumulativeGroupedAllocation( + public ReplacePricePriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) + ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15909,20 +81082,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationCadenceConverter))] -public enum ReplacePricePriceCumulativeGroupedAllocationCadence +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter))] +public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -15932,10 +81105,10 @@ public enum ReplacePricePriceCumulativeGroupedAllocationCadence Custom, } -sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override ReplacePricePriceCumulativeGroupedAllocationCadence Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15943,19 +81116,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - "semi_annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual, - "monthly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly, - "quarterly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly, - "one_time" => ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime, - "custom" => ReplacePricePriceCumulativeGroupedAllocationCadence.Custom, - _ => (ReplacePricePriceCumulativeGroupedAllocationCadence)(-1), + "annual" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom, + _ => (ReplacePricePriceGroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationCadence value, + ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -15963,12 +81136,12 @@ JsonSerializerOptions options writer, value switch { - ReplacePricePriceCumulativeGroupedAllocationCadence.Annual => "annual", - ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", - ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly => "monthly", - ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", - ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime => "one_time", - ReplacePricePriceCumulativeGroupedAllocationCadence.Custom => "custom", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -15979,86 +81152,89 @@ 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) - : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } + : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData ) { @@ -16067,7 +81243,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -16075,8 +81251,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16084,20 +81260,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( rawData ); } -[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] -public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -16114,7 +81290,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16123,7 +81299,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16132,7 +81308,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -16214,7 +81390,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -16250,16 +81426,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16278,18 +81454,18 @@ 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 - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -16297,13 +81473,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16368,7 +81557,7 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -16377,7 +81566,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -16386,51 +81575,54 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter) + typeof(JsonModelConverter< + ReplacePricePriceCumulativeGroupedAllocation, + ReplacePricePriceCumulativeGroupedAllocationFromRaw + >) )] -public sealed record class ReplacePricePriceMinimum : JsonModel +public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "cadence" - ); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// The id of the item the price will be associated with. + /// Configuration for cumulative_grouped_allocation pricing /// - public required string ItemID + public required ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } } /// - /// Configuration for minimum pricing + /// The id of the item the price will be associated with. /// - public required ReplacePricePriceMinimumMinimumConfig MinimumConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("item_id", value); } } /// @@ -16518,12 +81710,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" ); } @@ -16614,6 +81806,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 @@ -16653,9 +81858,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"); } @@ -16671,35 +81881,43 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceMinimum() + public ReplacePricePriceCumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public ReplacePricePriceMinimum(ReplacePricePriceMinimum replacePricePriceMinimum) - : base(replacePricePriceMinimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceCumulativeGroupedAllocation( + ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation + ) + : base(replacePricePriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public ReplacePricePriceMinimum(IReadOnlyDictionary rawData) + public ReplacePricePriceCumulativeGroupedAllocation( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimum(FrozenDictionary rawData) + ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceMinimum FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16707,19 +81925,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceMinimumFromRaw : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public ReplacePricePriceMinimum FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceMinimum.FromRawUnchecked(rawData); + ) => ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceMinimumCadenceConverter))] -public enum ReplacePricePriceMinimumCadence +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationCadenceConverter))] +public enum ReplacePricePriceCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -16729,10 +81948,10 @@ public enum ReplacePricePriceMinimumCadence Custom, } -sealed class ReplacePricePriceMinimumCadenceConverter - : JsonConverter +sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override ReplacePricePriceMinimumCadence Read( + public override ReplacePricePriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16740,19 +81959,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => ReplacePricePriceMinimumCadence.Annual, - "semi_annual" => ReplacePricePriceMinimumCadence.SemiAnnual, - "monthly" => ReplacePricePriceMinimumCadence.Monthly, - "quarterly" => ReplacePricePriceMinimumCadence.Quarterly, - "one_time" => ReplacePricePriceMinimumCadence.OneTime, - "custom" => ReplacePricePriceMinimumCadence.Custom, - _ => (ReplacePricePriceMinimumCadence)(-1), + "annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + "semi_annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly, + "quarterly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly, + "one_time" => ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime, + "custom" => ReplacePricePriceCumulativeGroupedAllocationCadence.Custom, + _ => (ReplacePricePriceCumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceMinimumCadence value, + ReplacePricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -16760,12 +81979,12 @@ JsonSerializerOptions options writer, value switch { - ReplacePricePriceMinimumCadence.Annual => "annual", - ReplacePricePriceMinimumCadence.SemiAnnual => "semi_annual", - ReplacePricePriceMinimumCadence.Monthly => "monthly", - ReplacePricePriceMinimumCadence.Quarterly => "quarterly", - ReplacePricePriceMinimumCadence.OneTime => "one_time", - ReplacePricePriceMinimumCadence.Custom => "custom", + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual => "annual", + ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly => "monthly", + ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", + ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime => "one_time", + ReplacePricePriceCumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -16776,104 +81995,128 @@ 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) - : base(replacePricePriceMinimumMinimumConfig) { } + : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceMinimumMinimumConfig(IReadOnlyDictionary rawData) + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimumMinimumConfig(FrozenDictionary rawData) + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public ReplacePricePriceMinimumMinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class ReplacePricePriceMinimumMinimumConfigFromRaw - : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceMinimumMinimumConfig.FromRawUnchecked(rawData); + ) => + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + rawData + ); } -[JsonConverter(typeof(ReplacePricePriceMinimumConversionRateConfigConverter))] -public record class ReplacePricePriceMinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] +public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -16890,7 +82133,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16899,7 +82142,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16908,7 +82151,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -16990,7 +82233,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -17026,16 +82269,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -17054,16 +82297,18 @@ 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) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals( + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -17071,13 +82316,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplacePricePriceMinimumConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceMinimumConversionRateConfig? Read( + public override ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17142,14 +82400,16 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceMinimumConversionRateConfig(element); + return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + element + ); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceMinimumConversionRateConfig value, + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -17386,6 +82646,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 @@ -17443,6 +82716,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -17452,8 +82726,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) { @@ -17579,10 +82856,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) { @@ -17810,10 +83090,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() { @@ -17821,7 +83101,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePricePercentConversionRateConfigConverter @@ -18136,6 +83429,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 @@ -18198,6 +83504,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -18207,8 +83514,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) { @@ -18365,10 +83675,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 @@ -18598,10 +83911,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() { @@ -18609,7 +83922,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceEventOutputConversionRateConfigConverter diff --git a/src/Orb/Models/Beta/BetaFetchPlanVersionParams.cs b/src/Orb/Models/Beta/BetaFetchPlanVersionParams.cs index 2ed83f89a..523875a4a 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,36 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/BetaSetDefaultPlanVersionParams.cs b/src/Orb/Models/Beta/BetaSetDefaultPlanVersionParams.cs index afc5ef444..c4bcb9333 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs index 3e4b88ad3..4573a3350 100644 --- a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs +++ b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDCreatePlanVersionParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Beta.ExternalPlanID; /// /// This endpoint allows the creation of a new plan version for an existing plan. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ExternalPlanIDCreatePlanVersionParams : ParamsBase +public record class ExternalPlanIDCreatePlanVersionParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -41,18 +45,18 @@ public required long Version /// /// Additional adjustments to be added to the plan. /// - public IReadOnlyList? AddAdjustments + public IReadOnlyList? AddAdjustments { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct< - ImmutableArray - >("add_adjustments"); + return this._rawBodyData.GetNullableStruct>( + "add_adjustments" + ); } init { - this._rawBodyData.Set?>( + this._rawBodyData.Set?>( "add_adjustments", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -62,18 +66,16 @@ public required long Version /// /// Additional prices to be added to the plan. /// - public IReadOnlyList? AddPrices + public IReadOnlyList? AddPrices { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct< - ImmutableArray - >("add_prices"); + return this._rawBodyData.GetNullableStruct>("add_prices"); } init { - this._rawBodyData.Set?>( + this._rawBodyData.Set?>( "add_prices", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -83,18 +85,18 @@ public required long Version /// /// Adjustments to be removed from the plan. /// - public IReadOnlyList? RemoveAdjustments + public IReadOnlyList? RemoveAdjustments { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct< - ImmutableArray - >("remove_adjustments"); + return this._rawBodyData.GetNullableStruct>( + "remove_adjustments" + ); } init { - this._rawBodyData.Set?>( + this._rawBodyData.Set?>( "remove_adjustments", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -104,18 +106,18 @@ public required long Version /// /// Prices to be removed from the plan. /// - public IReadOnlyList? RemovePrices + public IReadOnlyList? RemovePrices { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct< - ImmutableArray - >("remove_prices"); + return this._rawBodyData.GetNullableStruct>( + "remove_prices" + ); } init { - this._rawBodyData.Set?>( + this._rawBodyData.Set?>( "remove_prices", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -125,18 +127,18 @@ public required long Version /// /// Adjustments to be replaced with additional adjustments on the plan. /// - public IReadOnlyList? ReplaceAdjustments + public IReadOnlyList? ReplaceAdjustments { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct< - ImmutableArray - >("replace_adjustments"); + return this._rawBodyData.GetNullableStruct>( + "replace_adjustments" + ); } init { - this._rawBodyData.Set?>( + this._rawBodyData.Set?>( "replace_adjustments", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -146,18 +148,18 @@ public required long Version /// /// Prices to be replaced with additional prices on the plan. /// - public IReadOnlyList? ReplacePrices + public IReadOnlyList? ReplacePrices { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct< - ImmutableArray - >("replace_prices"); + return this._rawBodyData.GetNullableStruct>( + "replace_prices" + ); } init { - this._rawBodyData.Set?>( + this._rawBodyData.Set?>( "replace_prices", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -179,6 +181,8 @@ public bool? SetAsDefault public ExternalPlanIDCreatePlanVersionParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalPlanIDCreatePlanVersionParams( ExternalPlanIDCreatePlanVersionParams externalPlanIDCreatePlanVersionParams ) @@ -188,6 +192,7 @@ ExternalPlanIDCreatePlanVersionParams externalPlanIDCreatePlanVersionParams this._rawBodyData = new(externalPlanIDCreatePlanVersionParams._rawBodyData); } +#pragma warning restore CS8618 public ExternalPlanIDCreatePlanVersionParams( IReadOnlyDictionary rawHeaderData, @@ -228,6 +233,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + public virtual bool Equals(ExternalPlanIDCreatePlanVersionParams? other) + { + if (other == null) + { + return false; + } + return (this.ExternalPlanID?.Equals(other.ExternalPlanID) ?? other.ExternalPlanID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -256,27 +291,25 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.AddAdjustment, - global::Orb.Models.Beta.ExternalPlanID.AddAdjustmentFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class AddAdjustment : JsonModel { /// /// The definition of a new adjustment to create and add to the plan. /// - public required global::Orb.Models.Beta.ExternalPlanID.Adjustment Adjustment + public required Adjustment Adjustment { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "adjustment" - ); + return this._rawData.GetNotNullClass("adjustment"); } init { this._rawData.Set("adjustment", value); } } @@ -303,8 +336,11 @@ public override void Validate() public AddAdjustment() { } - public AddAdjustment(global::Orb.Models.Beta.ExternalPlanID.AddAdjustment addAdjustment) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public AddAdjustment(AddAdjustment addAdjustment) : base(addAdjustment) { } +#pragma warning restore CS8618 public AddAdjustment(IReadOnlyDictionary rawData) { @@ -319,34 +355,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 +661,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,10 +696,10 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Beta.ExternalPlanID.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() { @@ -684,12 +707,28 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + 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 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 +853,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 +868,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 { /// @@ -850,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. /// @@ -866,14 +915,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); } } @@ -882,14 +929,18 @@ public long? PlanPhaseOrder public override void Validate() { this.AllocationPrice?.Validate(); + this.LicenseAllocationPrice?.Validate(); _ = this.PlanPhaseOrder; this.Price?.Validate(); } public AddPrice() { } - public AddPrice(global::Orb.Models.Beta.ExternalPlanID.AddPrice addPrice) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public AddPrice(AddPrice addPrice) : base(addPrice) { } +#pragma warning restore CS8618 public AddPrice(IReadOnlyDictionary rawData) { @@ -904,28 +955,25 @@ 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. +/// The license allocation price to add to the plan. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.PriceConverter))] -public record class Price : ModelBase +[JsonConverter(typeof(LicenseAllocationPriceConverter))] +public record class LicenseAllocationPrice : ModelBase { public object? Value { get; } = null; @@ -947,77 +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, - minimum: (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, - minimum: (x) => x.Name, - newPlanMinimumComposite: (x) => x.Name, + minimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name ); @@ -1029,36 +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, - minimum: (x) => x.BillableMetricID, - newPlanMinimumComposite: (x) => x.BillableMetricID, + minimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID ); @@ -1070,36 +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, - minimum: (x) => x.BilledInAdvance, - newPlanMinimumComposite: (x) => x.BilledInAdvance, + minimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance ); @@ -1111,36 +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, - minimum: (x) => x.BillingCycleConfiguration, - newPlanMinimumComposite: (x) => x.BillingCycleConfiguration, + minimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration ); @@ -1152,36 +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, - minimum: (x) => x.ConversionRate, - newPlanMinimumComposite: (x) => x.ConversionRate, + minimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate ); @@ -1193,36 +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, - minimum: (x) => x.Currency, - newPlanMinimumComposite: (x) => x.Currency, + minimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency ); @@ -1234,36 +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, - minimum: (x) => x.DimensionalPriceConfiguration, - newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, + minimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration ); @@ -1275,36 +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, - minimum: (x) => x.ExternalPriceID, - newPlanMinimumComposite: (x) => x.ExternalPriceID, + minimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID ); @@ -1316,36 +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, - minimum: (x) => x.FixedPriceQuantity, - newPlanMinimumComposite: (x) => x.FixedPriceQuantity, + minimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity ); @@ -1357,36 +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, - minimum: (x) => x.InvoiceGroupingKey, - newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, + minimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey ); @@ -1398,1020 +1475,977 @@ 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, - minimum: (x) => x.InvoicingCycleConfiguration, - newPlanMinimumComposite: (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( - 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, - minimum: (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) - { - this.Value = value; - this._element = element; - } - - public Price(NewPlanTieredPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Unit value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanBulkPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Tiered value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price( - global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters value, - JsonElement? element = null - ) + public LicenseAllocationPrice(Bulk value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(BulkWithFilters value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMatrixPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Package value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Matrix value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanTieredPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(ThresholdTotalAmount value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredPackage value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedTieredPrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredWithMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanTieredPackageWithMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedTiered value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredPackageWithMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanUnitWithPercentPrice value, JsonElement? element = null) + public LicenseAllocationPrice(PackageWithAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(UnitWithPercent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration value, - JsonElement? element = null - ) + public LicenseAllocationPrice(MatrixWithAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanUnitWithProrationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedAllocationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(UnitWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanBulkWithProrationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedWithProratedMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(BulkWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedWithMeteredMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedWithProratedMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price( - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds value, - JsonElement? element = null - ) + public LicenseAllocationPrice(GroupedWithMeteredMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedWithMinMaxThresholds value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(MatrixWithDisplayName value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedTieredPackage value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanScalableMatrixWithUnitPricingPrice value, JsonElement? element = null) + public LicenseAllocationPrice(MaxGroupTieredPackage value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanScalableMatrixWithTieredPricingPrice value, JsonElement? element = null) + public LicenseAllocationPrice(ScalableMatrixWithUnitPricing value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) + public LicenseAllocationPrice( + ScalableMatrixWithTieredPricing value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public Price( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation value, - JsonElement? element = null - ) + public LicenseAllocationPrice(CumulativeGroupedBulk value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price(global::Orb.Models.Beta.ExternalPlanID.Minimum 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(global::Orb.Models.Beta.ExternalPlanID.Percent value, JsonElement? element = null) + public LicenseAllocationPrice(Percent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public Price( - global::Orb.Models.Beta.ExternalPlanID.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; } /// /// 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; } /// /// 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; } /// /// 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; } /// /// 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; } /// /// 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; } /// /// 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; } /// /// 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 - ) - { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.Minimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] out global::Orb.Models.Beta.ExternalPlanID.Minimum? value + [NotNullWhen(true)] out CumulativeGroupedAllocation? value ) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.Minimum; + 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.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; } /// /// 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; } @@ -2429,177 +2463,174 @@ public bool TryPickEventOutput( /// /// /// instance.Switch( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.TieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.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) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.Percent value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.EventOutput value) => {...} + /// (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 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 + 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 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 global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters value: + 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 global::Orb.Models.Beta.ExternalPlanID.TieredWithProration value: + 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 global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds value: + 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 global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation value: + case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case global::Orb.Models.Beta.ExternalPlanID.Minimum value: - minimum(value); + case MinimumComposite value: + minimumComposite(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: - throw new OrbInvalidDataException("Data did not match any variant of Price"); + throw new OrbInvalidDataException( + "Data did not match any variant of LicenseAllocationPrice" + ); } } @@ -2618,266 +2649,189 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.TieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.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) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.Percent value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.EventOutput value) => {...} + /// (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 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< - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration, - T - > 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 newPlanMatrixWithDisplayName, - System::Func newPlanGroupedTieredPackage, - System::Func newPlanMaxGroupTieredPackage, - System::Func< - NewPlanScalableMatrixWithUnitPricingPrice, - T - > newPlanScalableMatrixWithUnitPricing, - System::Func< - NewPlanScalableMatrixWithTieredPricingPrice, - T - > newPlanScalableMatrixWithTieredPricing, - System::Func newPlanCumulativeGroupedBulk, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, - System::Func newPlanMinimumComposite, - System::Func percent, - System::Func eventOutput + 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 { - NewPlanUnitPrice value => newPlanUnit(value), - NewPlanTieredPrice value => newPlanTiered(value), - NewPlanBulkPrice value => newPlanBulk(value), - global::Orb.Models.Beta.ExternalPlanID.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), - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration value => tieredWithProration( - value - ), - NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), - NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), - NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), - NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( - value - ), - NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds value => - groupedWithMinMaxThresholds(value), - NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), - NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), - NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), - NewPlanScalableMatrixWithUnitPricingPrice value => newPlanScalableMatrixWithUnitPricing( - value + 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" ), - 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), - NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), - global::Orb.Models.Beta.ExternalPlanID.Percent value => percent(value), - global::Orb.Models.Beta.ExternalPlanID.EventOutput value => eventOutput(value), - _ => throw new OrbInvalidDataException("Data did not match any variant of Price"), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanUnitPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanTieredPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(Unit value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanBulkPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(Tiered 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 LicenseAllocationPrice(Bulk value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanPackagePrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(BulkWithFilters value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMatrixPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(Package value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanThresholdTotalAmountPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(Matrix value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanTieredPackagePrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(ThresholdTotalAmount value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanTieredWithMinimumPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(TieredPackage value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedTieredPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(TieredWithMinimum value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanTieredPackageWithMinimumPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedTiered value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanPackageWithAllocationPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(TieredPackageWithMinimum value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanUnitWithPercentPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(PackageWithAllocation value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMatrixWithAllocationPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(UnitWithPercent 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 LicenseAllocationPrice(MatrixWithAllocation value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanUnitWithProrationPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(TieredWithProration value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedAllocationPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(UnitWithProration value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanBulkWithProrationPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedAllocation value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(BulkWithProration value) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedWithProratedMinimum 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 LicenseAllocationPrice(GroupedWithMeteredMinimum value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMatrixWithDisplayNamePrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedWithMinMaxThresholds value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanGroupedTieredPackagePrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(MatrixWithDisplayName value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMaxGroupTieredPackagePrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedTieredPackage value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(MaxGroupTieredPackage value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(ScalableMatrixWithUnitPricing value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanCumulativeGroupedBulkPrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(ScalableMatrixWithTieredPricing 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 LicenseAllocationPrice(CumulativeGroupedBulk 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 LicenseAllocationPrice(CumulativeGroupedAllocation value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.Price( - NewPlanMinimumCompositePrice value - ) => new(value); + public static implicit operator LicenseAllocationPrice(MinimumComposite 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 LicenseAllocationPrice(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 LicenseAllocationPrice(EventOutput value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2893,50 +2847,49 @@ 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(), - (minimum) => minimum.Validate(), - (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), + (minimumComposite) => minimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() ); } - public virtual bool Equals(global::Orb.Models.Beta.ExternalPlanID.Price? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(LicenseAllocationPrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2944,12 +2897,54 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + 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 PriceConverter : JsonConverter +sealed class LicenseAllocationPriceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.Price? Read( + public override LicenseAllocationPrice? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2972,10 +2967,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2994,10 +2986,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3016,10 +3005,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3038,11 +3024,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3061,10 +3046,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3083,10 +3065,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3105,7 +3084,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3127,10 +3106,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3149,7 +3125,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3171,10 +3147,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3193,11 +3166,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3216,11 +3188,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3239,7 +3210,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3261,7 +3232,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3283,11 +3254,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3306,7 +3276,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3328,7 +3298,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3350,7 +3320,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3372,11 +3342,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3395,11 +3364,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3418,11 +3386,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3441,12 +3408,11 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) { deserialized.Validate(); return new(deserialized, element); @@ -3464,7 +3430,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3486,11 +3452,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3509,11 +3474,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3532,11 +3496,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3555,11 +3518,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3578,34 +3540,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -3624,7 +3562,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3646,11 +3584,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3669,11 +3603,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3690,14 +3620,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.Price(element); + return new LicenseAllocationPrice(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.Price? value, + LicenseAllocationPrice? value, JsonSerializerOptions options ) { @@ -3705,55 +3635,56 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters, - global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersFromRaw - >) -)] -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 global::Orb.Models.Beta.ExternalPlanID.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< - ApiEnum - >("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); } } /// @@ -3782,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. /// @@ -3841,14 +3785,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); } } @@ -3937,6 +3879,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 @@ -3975,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(); @@ -3999,379 +3953,194 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public BulkWithFilters() + public Unit() { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("unit"); } - public BulkWithFilters(global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters bulkWithFilters) - : base(bulkWithFilters) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Unit FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class BulkWithFiltersFromRaw : IFromRawJson +class UnitFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.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< - global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig, - global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfigFromRaw - >) -)] -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< - 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 BulkWithFiltersConfig() { } + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} - public BulkWithFiltersConfig( - global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig bulkWithFiltersConfig +sealed class CadenceConverter : JsonConverter +{ + public override Cadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) - : base(bulkWithFiltersConfig) { } - - public BulkWithFiltersConfig(IReadOnlyDictionary rawData) { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkWithFiltersConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); + 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), + }; } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.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 global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a single property filter -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.Filter, - global::Orb.Models.Beta.ExternalPlanID.FilterFromRaw - >) -)] -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() { } - - public Filter(global::Orb.Models.Beta.ExternalPlanID.Filter filter) - : base(filter) { } - - 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 global::Orb.Models.Beta.ExternalPlanID.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class FilterFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.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 - >) -)] -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() { } - public Tier(global::Orb.Models.Beta.ExternalPlanID.Tier tier) - : base(tier) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Beta.ExternalPlanID.Tier FromRawUnchecked( + /// + 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 global::Orb.Models.Beta.ExternalPlanID.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Tier.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.CadenceConverter))] -public enum Cadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class CadenceConverter : JsonConverter -{ - public override global::Orb.Models.Beta.ExternalPlanID.Cadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - 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), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.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", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } + public LicenseAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => + LicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfigConverter))] +[JsonConverter(typeof(ConversionRateConfigConverter))] public record class ConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4524,13 +4293,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,10 +4320,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Beta.ExternalPlanID.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() { @@ -4564,13 +4331,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -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 +4414,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 +4429,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationFromRaw - >) -)] -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< - 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); } } @@ -4689,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 /// @@ -4716,18 +4508,16 @@ public required string Name } /// - /// Configuration for tiered_with_proration pricing + /// Configuration for tiered pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.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); } } /// @@ -4789,12 +4579,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 TieredConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4885,6 +4675,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 @@ -4925,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(); @@ -4947,58 +4749,56 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public TieredWithProration() + public Tiered() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("tiered"); } - public TieredWithProration( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration tieredWithProration - ) - : base(tieredWithProration) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Beta.ExternalPlanID.TieredWithProration FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Tiered FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class TieredWithProrationFromRaw - : IFromRawJson +class TieredFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.TieredWithProration FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.TieredWithProration.FromRawUnchecked(rawData); + public Tiered FromRawUnchecked(IReadOnlyDictionary rawData) => + Tiered.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadenceConverter))] -public enum TieredWithProrationCadence +[JsonConverter(typeof(TieredCadenceConverter))] +public enum TieredCadence { Annual, SemiAnnual, @@ -5008,10 +4808,9 @@ public enum TieredWithProrationCadence Custom, } -sealed class TieredWithProrationCadenceConverter - : JsonConverter +sealed class TieredCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence Read( + public override TieredCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5019,29 +4818,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" => 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, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence value, + TieredCadence value, JsonSerializerOptions options ) { @@ -5049,18 +4838,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", + 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)) ), @@ -5070,160 +4853,79 @@ JsonSerializerOptions options } } -/// -/// Configuration for tiered_with_proration pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigFromRaw - >) -)] -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< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - public override void Validate() - { - foreach (var item in this.Tiers) - { - item.Validate(); + return this._rawData.GetNotNullClass("amount"); } + init { this._rawData.Set("amount", value); } } - public TieredWithProrationConfig() { } - - public TieredWithProrationConfig( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig tieredWithProrationConfig - ) - : base(tieredWithProrationConfig) { } - - 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 global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public TieredWithProrationConfig( - IReadOnlyList tiers - ) - : this() - { - this.Tiers = tiers; - } -} - -class TieredWithProrationConfigFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.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 - >) -)] -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() { } - public TieredWithProrationConfigTier( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier tieredWithProrationConfigTier - ) - : base(tieredWithProrationConfigTier) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier FromRawUnchecked( + /// + public static TieredLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5231,22 +4933,16 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationConfigTierFromRaw - : IFromRawJson +class TieredLicenseAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier FromRawUnchecked( + public TieredLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier.FromRawUnchecked( - rawData - ); + ) => TieredLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfigConverter) -)] -public record class TieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(TieredConversionRateConfigConverter))] +public record class TieredConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5263,7 +4959,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public TieredConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5272,7 +4968,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public TieredConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5281,7 +4977,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public TieredConversionRateConfig(JsonElement element) { this._element = element; } @@ -5363,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" ); } } @@ -5399,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 global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig( + public static implicit operator TieredConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig( + public static implicit operator TieredConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5427,18 +5123,16 @@ 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( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig? 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() { @@ -5446,13 +5140,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class TieredWithProrationConversionRateConfigConverter - : JsonConverter +sealed class TieredConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig? Read( + public override TieredConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5517,16 +5223,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig( - element - ); + return new TieredConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig value, + TieredConversionRateConfig value, JsonSerializerOptions options ) { @@ -5534,48 +5238,33 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsFromRaw - >) -)] -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< - string, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence - > Cadence + public required BulkConfig BulkConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence - > - >("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 global::Orb.Models.Beta.ExternalPlanID.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); } } /// @@ -5591,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 /// @@ -5676,12 +5388,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 BulkConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5772,6 +5484,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 @@ -5810,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"); } @@ -5834,63 +5558,56 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public GroupedWithMinMaxThresholds() + public Bulk() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("bulk"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) - : base(groupedWithMinMaxThresholds) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Bulk FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class BulkFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds.FromRawUnchecked( - rawData - ); + public Bulk FromRawUnchecked(IReadOnlyDictionary rawData) => + Bulk.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadenceConverter) -)] -public enum GroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(BulkCadenceConverter))] +public enum BulkCadence { Annual, SemiAnnual, @@ -5900,10 +5617,9 @@ public enum GroupedWithMinMaxThresholdsCadence Custom, } -sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class BulkCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence Read( + public override BulkCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5911,49 +5627,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" => 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, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence value, + BulkCadence value, JsonSerializerOptions options ) { @@ -5961,26 +5647,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", + 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)) ), @@ -5990,100 +5662,79 @@ JsonSerializerOptions options } } -/// -/// Configuration for grouped_with_min_max_thresholds pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Beta.ExternalPlanID.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() { } - public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig - ) - : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static BulkLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6091,22 +5742,16 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class BulkLicenseAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public BulkLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked( - rawData - ); + ) => BulkLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] -public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(BulkConversionRateConfigConverter))] +public record class BulkConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6123,7 +5768,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public BulkConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6132,7 +5777,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public BulkConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6141,7 +5786,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public BulkConversionRateConfig(JsonElement element) { this._element = element; } @@ -6223,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" ); } } @@ -6259,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 global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator BulkConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator BulkConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6287,18 +5932,16 @@ 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( - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig? 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() { @@ -6306,13 +5949,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class BulkConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override BulkConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6377,16 +6032,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new BulkConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig value, + BulkConversionRateConfig value, JsonSerializerOptions options ) { @@ -6394,48 +6047,35 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationFromRaw - >) -)] -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< - string, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence - > Cadence + public required BulkWithFiltersConfig BulkWithFiltersConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence - > - >("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 global::Orb.Models.Beta.ExternalPlanID.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); } } /// @@ -6451,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 /// @@ -6536,12 +6199,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 BulkWithFiltersConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6632,6 +6295,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 @@ -6670,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") ) ) { @@ -6694,37 +6374,131 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public CumulativeGroupedAllocation() + public BulkWithFilters() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) - : base(cumulativeGroupedAllocation) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 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 global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation FromRawUnchecked( + /// + public static BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6732,25 +6506,174 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class BulkWithFiltersConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation FromRawUnchecked( + public BulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.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(global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadenceConverter) -)] -public enum CumulativeGroupedAllocationCadence +[JsonConverter(typeof(BulkWithFiltersCadenceConverter))] +public enum BulkWithFiltersCadence { Annual, SemiAnnual, @@ -6760,10 +6683,9 @@ public enum CumulativeGroupedAllocationCadence Custom, } -sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class BulkWithFiltersCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence Read( + public override BulkWithFiltersCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6771,49 +6693,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" => 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, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence value, + BulkWithFiltersCadence value, JsonSerializerOptions options ) { @@ -6821,26 +6713,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", + 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)) ), @@ -6850,100 +6728,86 @@ JsonSerializerOptions options } } -/// -/// Configuration for cumulative_grouped_allocation pricing -/// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfigFromRaw + BulkWithFiltersLicenseAllocation, + BulkWithFiltersLicenseAllocationFromRaw >) )] -public sealed record class CumulativeGroupedAllocationConfig : JsonModel +public sealed record class BulkWithFiltersLicenseAllocation : 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 + /// The amount of credits granted per active license per cadence. /// - public required string GroupAllocation + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("group_allocation", value); } + init { this._rawData.Set("amount", value); } } /// - /// The event property used to group usage before applying allocations + /// The currency of the license allocation. /// - public required string GroupingKey + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("currency"); } - 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() { } - public CumulativeGroupedAllocationConfig( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static BulkWithFiltersLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6951,22 +6815,16 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class BulkWithFiltersLicenseAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig FromRawUnchecked( + public BulkWithFiltersLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig.FromRawUnchecked( - rawData - ); + ) => BulkWithFiltersLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfigConverter) -)] -public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(BulkWithFiltersConversionRateConfigConverter))] +public record class BulkWithFiltersConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6983,7 +6841,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public BulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6992,7 +6850,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public BulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7001,7 +6859,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public BulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -7083,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" ); } } @@ -7119,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 global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator BulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator BulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7147,18 +7005,16 @@ 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( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig? 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() { @@ -7166,13 +7022,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class CumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class BulkWithFiltersConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig? Read( + public override BulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7237,16 +7106,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig( - element - ); + return new BulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig value, + BulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -7254,25 +7121,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.Minimum, - global::Orb.Models.Beta.ExternalPlanID.MinimumFromRaw - >) -)] -public sealed record class Minimum : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class 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< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -7291,18 +7151,26 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// 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 global::Orb.Models.Beta.ExternalPlanID.MinimumConfig MinimumConfig + public required IReadOnlyList LicenseAllocations { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) ); } - init { this._rawData.Set("minimum_config", value); } } /// @@ -7331,6 +7199,19 @@ public required string 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. /// @@ -7390,12 +7271,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 PackageConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7486,6 +7367,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 @@ -7526,12 +7420,16 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + 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(); @@ -7543,55 +7441,56 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Minimum() + public Package() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("package"); } - public Minimum(global::Orb.Models.Beta.ExternalPlanID.Minimum minimum) - : base(minimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Package(Package package) + : base(package) { } +#pragma warning restore CS8618 - public Minimum(IReadOnlyDictionary rawData) + public Package(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("package"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + Package(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Package FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class PackageFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Minimum.FromRawUnchecked(rawData); + public Package FromRawUnchecked(IReadOnlyDictionary rawData) => + Package.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.MinimumCadenceConverter))] -public enum MinimumCadence +[JsonConverter(typeof(PackageCadenceConverter))] +public enum PackageCadence { Annual, SemiAnnual, @@ -7601,10 +7500,9 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter - : JsonConverter +sealed class PackageCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.MinimumCadence Read( + public override PackageCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7612,19 +7510,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" => 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, - global::Orb.Models.Beta.ExternalPlanID.MinimumCadence value, + PackageCadence value, JsonSerializerOptions options ) { @@ -7632,12 +7530,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", + 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)) ), @@ -7647,102 +7545,98 @@ JsonSerializerOptions options } } -/// -/// Configuration for minimum pricing -/// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.MinimumConfig, - global::Orb.Models.Beta.ExternalPlanID.MinimumConfigFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class MinimumConfig : JsonModel +public sealed record class PackageLicenseAllocation : JsonModel { /// - /// The minimum amount to apply + /// The amount of credits granted per active license per cadence. /// - public required string MinimumAmount + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("amount", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// The currency of the license allocation. /// - public bool? Prorated + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNotNullClass("currency"); } - init - { - if (value == null) - { - return; - } + init { this._rawData.Set("currency", value); } + } - this._rawData.Set("prorated", 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.MinimumAmount; - _ = this.Prorated; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public MinimumConfig() { } + public PackageLicenseAllocation() { } - public MinimumConfig(global::Orb.Models.Beta.ExternalPlanID.MinimumConfig minimumConfig) - : base(minimumConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PackageLicenseAllocation(PackageLicenseAllocation packageLicenseAllocation) + : base(packageLicenseAllocation) { } +#pragma warning restore CS8618 - public MinimumConfig(IReadOnlyDictionary rawData) + public PackageLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + PackageLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.MinimumConfig FromRawUnchecked( + /// + public static PackageLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class MinimumConfigFromRaw : IFromRawJson +class PackageLicenseAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.MinimumConfig FromRawUnchecked( + public PackageLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.MinimumConfig.FromRawUnchecked(rawData); + ) => PackageLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(PackageConversionRateConfigConverter))] +public record class PackageConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7759,7 +7653,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public PackageConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7768,7 +7662,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public PackageConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7777,7 +7671,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public PackageConversionRateConfig(JsonElement element) { this._element = element; } @@ -7859,7 +7753,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PackageConversionRateConfig" ); } } @@ -7895,16 +7789,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 PackageConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig( + public static implicit operator PackageConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig( + public static implicit operator PackageConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7923,18 +7817,16 @@ 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 PackageConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig? 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() { @@ -7942,13 +7834,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class MinimumConversionRateConfigConverter - : JsonConverter +sealed class PackageConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig? Read( + public override PackageConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8013,16 +7917,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig( - element - ); + return new PackageConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig value, + PackageConversionRateConfig value, JsonSerializerOptions options ) { @@ -8030,25 +7932,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.Percent, - global::Orb.Models.Beta.ExternalPlanID.PercentFromRaw - >) -)] -public sealed record class Percent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class 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< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -8067,44 +7962,65 @@ public required string ItemID } /// - /// The pricing model type + /// 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 JsonElement ModelType + public required IReadOnlyList LicenseAllocations { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("model_type", value); } } /// - /// The name of the price. + /// Configuration for matrix pricing /// - public required string Name + public required MatrixConfig MatrixConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNotNullClass("matrix_config"); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("matrix_config", value); } } /// - /// Configuration for percent pricing + /// The pricing model type /// - public required global::Orb.Models.Beta.ExternalPlanID.PercentConfig PercentConfig + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("percent_config", value); } + 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); } } /// @@ -8166,12 +8082,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 MatrixConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8262,6 +8178,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 @@ -8302,12 +8231,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(); + } + this.MatrixConfig.Validate(); + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("matrix"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -8319,55 +8252,56 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Percent() + public Matrix() { - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("matrix"); } - public Percent(global::Orb.Models.Beta.ExternalPlanID.Percent percent) - : base(percent) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Matrix(Matrix matrix) + : base(matrix) { } +#pragma warning restore CS8618 - public Percent(IReadOnlyDictionary rawData) + public Matrix(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("matrix"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Percent(FrozenDictionary rawData) + Matrix(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Matrix FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class MatrixFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Percent.FromRawUnchecked(rawData); + public Matrix FromRawUnchecked(IReadOnlyDictionary rawData) => + Matrix.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(MatrixCadenceConverter))] +public enum MatrixCadence { Annual, SemiAnnual, @@ -8377,10 +8311,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter - : JsonConverter +sealed class MatrixCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.PercentCadence Read( + public override MatrixCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8388,19 +8321,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" => 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, - global::Orb.Models.Beta.ExternalPlanID.PercentCadence value, + MatrixCadence value, JsonSerializerOptions options ) { @@ -8408,12 +8341,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", + 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)) ), @@ -8423,80 +8356,96 @@ JsonSerializerOptions options } } -/// -/// Configuration for percent pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.PercentConfig, - global::Orb.Models.Beta.ExternalPlanID.PercentConfigFromRaw - >) -)] -public sealed record class PercentConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixLicenseAllocation : 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 MatrixLicenseAllocation() { } - public PercentConfig(global::Orb.Models.Beta.ExternalPlanID.PercentConfig percentConfig) - : base(percentConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixLicenseAllocation(MatrixLicenseAllocation matrixLicenseAllocation) + : base(matrixLicenseAllocation) { } +#pragma warning restore CS8618 - public PercentConfig(IReadOnlyDictionary rawData) + public MatrixLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PercentConfig(FrozenDictionary rawData) + MatrixLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.PercentConfig FromRawUnchecked( + /// + public static MatrixLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public PercentConfig(double percent) - : this() - { - this.Percent = percent; - } } -class PercentConfigFromRaw : IFromRawJson +class MatrixLicenseAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.PercentConfig FromRawUnchecked( + public MatrixLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.PercentConfig.FromRawUnchecked(rawData); + ) => MatrixLicenseAllocation.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +[JsonConverter(typeof(MatrixConversionRateConfigConverter))] +public record class MatrixConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8513,7 +8462,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public MatrixConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8522,7 +8471,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public MatrixConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8531,7 +8480,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public MatrixConversionRateConfig(JsonElement element) { this._element = element; } @@ -8613,7 +8562,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of MatrixConversionRateConfig" ); } } @@ -8649,16 +8598,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 MatrixConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig( + public static implicit operator MatrixConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig( + public static implicit operator MatrixConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8677,18 +8626,16 @@ 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 MatrixConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig? 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() { @@ -8696,13 +8643,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class PercentConversionRateConfigConverter - : JsonConverter +sealed class MatrixConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig? Read( + public override MatrixConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8767,16 +8726,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig( - element - ); + return new MatrixConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig value, + MatrixConversionRateConfig value, JsonSerializerOptions options ) { @@ -8784,58 +8741,58 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.EventOutput, - global::Orb.Models.Beta.ExternalPlanID.EventOutputFromRaw - >) -)] -public sealed record class EventOutput : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ThresholdTotalAmount : 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); } } /// - /// Configuration for event_output pricing + /// The id of the item the price will be associated with. /// - public required global::Orb.Models.Beta.ExternalPlanID.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< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("item_id", value); } } /// @@ -8864,6 +8821,21 @@ public required string 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. /// @@ -8923,12 +8895,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 ThresholdTotalAmountConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -9019,6 +8991,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 @@ -9058,18 +9043,22 @@ public string? ReferenceID 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") + 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(); @@ -9081,35 +9070,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public EventOutput() + public ThresholdTotalAmount() { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); } - public EventOutput(global::Orb.Models.Beta.ExternalPlanID.EventOutput eventOutput) - : base(eventOutput) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdTotalAmount(ThresholdTotalAmount thresholdTotalAmount) + : base(thresholdTotalAmount) { } +#pragma warning restore CS8618 - public EventOutput(IReadOnlyDictionary rawData) + public ThresholdTotalAmount(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("threshold_total_amount"); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) + ThresholdTotalAmount(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.EventOutput FromRawUnchecked( + /// + public static ThresholdTotalAmount FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9117,19 +9110,19 @@ IReadOnlyDictionary rawData } } -class EventOutputFromRaw : IFromRawJson +class ThresholdTotalAmountFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.EventOutput FromRawUnchecked( + public ThresholdTotalAmount FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.EventOutput.FromRawUnchecked(rawData); + ) => ThresholdTotalAmount.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.EventOutputCadenceConverter))] -public enum EventOutputCadence +[JsonConverter(typeof(ThresholdTotalAmountCadenceConverter))] +public enum ThresholdTotalAmountCadence { Annual, SemiAnnual, @@ -9139,10 +9132,9 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter - : JsonConverter +sealed class ThresholdTotalAmountCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence Read( + public override ThresholdTotalAmountCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9150,19 +9142,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" => 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, - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence value, + ThresholdTotalAmountCadence value, JsonSerializerOptions options ) { @@ -9170,13 +9162,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", + 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)) ), @@ -9186,116 +9177,275 @@ JsonSerializerOptions options } } -/// -/// Configuration for event_output pricing -/// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig, - global::Orb.Models.Beta.ExternalPlanID.EventOutputConfigFromRaw + ThresholdTotalAmountLicenseAllocation, + ThresholdTotalAmountLicenseAllocationFromRaw >) )] -public sealed record class EventOutputConfig : JsonModel +public sealed record class ThresholdTotalAmountLicenseAllocation : 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 ThresholdTotalAmountLicenseAllocation() { } - public EventOutputConfig( - global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig eventOutputConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdTotalAmountLicenseAllocation( + ThresholdTotalAmountLicenseAllocation thresholdTotalAmountLicenseAllocation ) - : base(eventOutputConfig) { } + : base(thresholdTotalAmountLicenseAllocation) { } +#pragma warning restore CS8618 - public EventOutputConfig(IReadOnlyDictionary rawData) + public ThresholdTotalAmountLicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutputConfig(FrozenDictionary rawData) + ThresholdTotalAmountLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig FromRawUnchecked( + /// + 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 EventOutputConfig(string unitRatingKey) + 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.UnitRatingKey = unitRatingKey; + this.ConsumptionTable = consumptionTable; } } -class EventOutputConfigFromRaw - : IFromRawJson +class ThresholdTotalAmountConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig FromRawUnchecked( + public ThresholdTotalAmountConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig.FromRawUnchecked(rawData); + ) => ThresholdTotalAmountConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfigConverter) -)] -public record class EventOutputConversionRateConfig : ModelBase +/// +/// 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; @@ -9312,7 +9462,7 @@ public JsonElement Json } } - public EventOutputConversionRateConfig( + public ThresholdTotalAmountConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9321,7 +9471,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig( + public ThresholdTotalAmountConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9330,7 +9480,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig(JsonElement element) + public ThresholdTotalAmountConversionRateConfig(JsonElement element) { this._element = element; } @@ -9412,7 +9562,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of ThresholdTotalAmountConversionRateConfig" ); } } @@ -9448,16 +9598,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 ThresholdTotalAmountConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig( + public static implicit operator ThresholdTotalAmountConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig( + public static implicit operator ThresholdTotalAmountConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -9476,18 +9626,16 @@ 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 ThresholdTotalAmountConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig? 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() { @@ -9495,13 +9643,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class EventOutputConversionRateConfigConverter - : JsonConverter +sealed class ThresholdTotalAmountConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig? Read( + public override ThresholdTotalAmountConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9566,16 +9727,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig( - element - ); + return new ThresholdTotalAmountConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig value, + ThresholdTotalAmountConversionRateConfig value, JsonSerializerOptions options ) { @@ -9583,456 +9742,769 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment, - global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustmentFromRaw - >) -)] -public sealed record class RemoveAdjustment : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredPackage : 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); } - } - - /// - public override void Validate() - { - _ = this.AdjustmentID; - _ = this.PlanPhaseOrder; - } - - public RemoveAdjustment() { } - - public RemoveAdjustment( - global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment removeAdjustment - ) - : base(removeAdjustment) { } - - public RemoveAdjustment(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveAdjustment(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public RemoveAdjustment(string adjustmentID) - : this() - { - this.AdjustmentID = adjustmentID; + init { this._rawData.Set("item_id", value); } } -} - -class RemoveAdjustmentFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment.FromRawUnchecked(rawData); -} -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.RemovePrice, - global::Orb.Models.Beta.ExternalPlanID.RemovePriceFromRaw - >) -)] -public sealed record class RemovePrice : JsonModel -{ /// - /// The id of the price to remove from the plan. + /// 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 PriceID + public required IReadOnlyList LicenseAllocations { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("price_id"); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("price_id", value); } } /// - /// The phase to remove this price from. + /// The pricing model type /// - public long? PlanPhaseOrder + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("plan_phase_order", value); } - } - - /// - public override void Validate() - { - _ = this.PriceID; - _ = this.PlanPhaseOrder; + init { this._rawData.Set("model_type", value); } } - public RemovePrice() { } - - public RemovePrice(global::Orb.Models.Beta.ExternalPlanID.RemovePrice removePrice) - : base(removePrice) { } - - public RemovePrice(IReadOnlyDictionary rawData) + /// + /// The name of the price. + /// + public required string Name { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemovePrice(FrozenDictionary rawData) + /// + /// Configuration for tiered_package pricing + /// + public required TieredPackageConfig TieredPackageConfig { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tiered_package_config"); + } + init { this._rawData.Set("tiered_package_config", value); } } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.RemovePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } } - [SetsRequiredMembers] - public RemovePrice(string priceID) - : this() + /// + /// 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.PriceID = priceID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } } -} - -class RemovePriceFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.RemovePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.RemovePrice.FromRawUnchecked(rawData); -} -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment, - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentFromRaw - >) -)] -public sealed record class ReplaceAdjustment : JsonModel -{ /// - /// The definition of a new adjustment to create and add to the plan. + /// For custom cadence: specifies the duration of the billing period in days + /// or months. /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment Adjustment + public NewBillingCycleConfiguration? BillingCycleConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "adjustment" + return this._rawData.GetNullableClass( + "billing_cycle_configuration" ); } - init { this._rawData.Set("adjustment", value); } + init { this._rawData.Set("billing_cycle_configuration", value); } } /// - /// The id of the adjustment on the plan to replace in the plan. + /// The per unit conversion rate of the price currency to the invoicing currency. /// - public required string ReplacesAdjustmentID + public double? ConversionRate { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); + return this._rawData.GetNullableStruct("conversion_rate"); } - init { this._rawData.Set("replaces_adjustment_id", value); } + init { this._rawData.Set("conversion_rate", value); } } /// - /// The phase to replace this adjustment from. + /// The configuration for the rate of the price currency to the invoicing currency. /// - public long? PlanPhaseOrder + public TieredPackageConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); } - init { this._rawData.Set("plan_phase_order", value); } + init { this._rawData.Set("conversion_rate_config", value); } } - /// - public override void Validate() + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; - _ = this.PlanPhaseOrder; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } } - public ReplaceAdjustment() { } - - public ReplaceAdjustment( - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment replaceAdjustment - ) - : base(replaceAdjustment) { } - - public ReplaceAdjustment(IReadOnlyDictionary rawData) + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplaceAdjustment(FrozenDictionary rawData) + /// + /// An alias for the price. + /// + 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 global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + 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); } } -} - -class ReplaceAdjustmentFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment.FromRawUnchecked(rawData); -} - -/// -/// The definition of a new adjustment to create and add to the plan. -/// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustmentConverter))] -public record class ReplaceAdjustmentAdjustment : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - public JsonElement Json + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); } + init { this._rawData.Set("invoice_grouping_key", value); } } - public string? Currency + /// + /// 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 { - return Match( - newPercentageDiscount: (x) => x.Currency, - newUsageDiscount: (x) => x.Currency, - newAmountDiscount: (x) => x.Currency, - newMinimum: (x) => x.Currency, - newMaximum: (x) => x.Currency + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" ); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - public bool? IsInvoiceLevel + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { 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.GetNullableClass("license_type_id"); } + init { this._rawData.Set("license_type_id", value); } } - public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) - { - this.Value = value; - this._element = element; + /// + /// User-specified key/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 ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); + } + init { this._rawData.Set("reference_id", value); } } - public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + 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 ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) + public TieredPackage() { - this.Value = value; - this._element = element; + this.ModelType = JsonSerializer.SerializeToElement("tiered_package"); } - public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackage(TieredPackage tieredPackage) + : base(tieredPackage) { } +#pragma warning restore CS8618 + + public TieredPackage(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_package"); } - public ReplaceAdjustmentAdjustment(JsonElement element) +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredPackage(FrozenDictionary rawData) { - this._element = element; + 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 +{ /// - /// Returns true and sets the 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); - /// } - /// - /// + /// The amount of credits granted per active license per cadence. /// - public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) + public required string Amount { - value = this.Value as NewPercentageDiscount; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("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); - /// } - /// - /// + /// The currency of the license allocation. /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + public required string Currency { - value = this.Value as NewUsageDiscount; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", 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.TryPickNewAmountDiscount(out var value)) { - /// // `value` is of type `NewAmountDiscount` - /// Console.WriteLine(value); - /// } - /// - /// + /// When True, overage beyond the allocation is written off. /// - public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + public bool? WriteOffOverage { - value = this.Value as NewAmountDiscount; - return value != null; + 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 . + /// 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; } @@ -10050,43 +10522,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 TieredPackageConversionRateConfig" ); } } @@ -10106,54 +10563,33 @@ 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 TieredPackageConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - NewPercentageDiscount value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - NewUsageDiscount value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - NewAmountDiscount value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - NewMinimum value + public static implicit operator TieredPackageConversionRateConfig( + SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - NewMaximum value + public static implicit operator TieredPackageConversionRateConfig( + SharedTieredConversionRateConfig value ) => new(value); /// @@ -10171,24 +10607,16 @@ 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 TieredPackageConversionRateConfig" ); } - 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( - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment? 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() { @@ -10196,36 +10624,49 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplaceAdjustmentAdjustmentConverter - : JsonConverter +sealed class TieredPackageConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment? Read( + public override TieredPackageConversionRateConfig? 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": + case "unit": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -10243,11 +10684,11 @@ JsonSerializerOptions options return new(element); } - case "usage_discount": + case "tiered": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -10265,78 +10706,16 @@ JsonSerializerOptions options return new(element); } - case "amount_discount": + default: { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "maximum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - element - ); + return new TieredPackageConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment value, + TieredPackageConversionRateConfig value, JsonSerializerOptions options ) { @@ -10344,885 +10723,769 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePrice, - global::Orb.Models.Beta.ExternalPlanID.ReplacePriceFromRaw - >) -)] -public sealed record class ReplacePrice : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredWithMinimum : 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< + ImmutableArray + >("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 global::Orb.Models.Beta.ExternalPlanID.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() { } - - public ReplacePrice(global::Orb.Models.Beta.ExternalPlanID.ReplacePrice replacePrice) - : base(replacePrice) { } - - public ReplacePrice(IReadOnlyDictionary rawData) + /// + /// Configuration for tiered_with_minimum pricing + /// + public required TieredWithMinimumConfig TieredWithMinimumConfig { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_minimum_config" + ); + } + init { this._rawData.Set("tiered_with_minimum_config", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePrice(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 global::Orb.Models.Beta.ExternalPlanID.ReplacePrice 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 ReplacePrice(string replacesPriceID) - : this() + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration { - this.ReplacesPriceID = replacesPriceID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } } -} - -class ReplacePriceFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.ReplacePrice.FromRawUnchecked(rawData); -} - -/// -/// New plan price request body params. -/// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceConverter))] -public record class ReplacePricePrice : ModelBase -{ - public object? Value { get; } = null; - JsonElement? _element = null; + /// + /// 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 JsonElement Json + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public TieredWithMinimumConversionRateConfig? ConversionRateConfig { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" ); } + init { this._rawData.Set("conversion_rate_config", value); } } - public string ItemID + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency { get { - return Match( - newPlanUnit: (x) => x.ItemID, - newPlanTiered: (x) => x.ItemID, - newPlanBulk: (x) => x.ItemID, - bulkWithFilters: (x) => x.ItemID, - newPlanPackage: (x) => x.ItemID, - newPlanMatrix: (x) => x.ItemID, - newPlanThresholdTotalAmount: (x) => x.ItemID, - newPlanTieredPackage: (x) => x.ItemID, - newPlanTieredWithMinimum: (x) => x.ItemID, - newPlanGroupedTiered: (x) => x.ItemID, - newPlanTieredPackageWithMinimum: (x) => x.ItemID, - newPlanPackageWithAllocation: (x) => x.ItemID, - newPlanUnitWithPercent: (x) => x.ItemID, - newPlanMatrixWithAllocation: (x) => x.ItemID, - tieredWithProration: (x) => x.ItemID, - newPlanUnitWithProration: (x) => x.ItemID, - newPlanGroupedAllocation: (x) => x.ItemID, - newPlanBulkWithProration: (x) => x.ItemID, - newPlanGroupedWithProratedMinimum: (x) => x.ItemID, - newPlanGroupedWithMeteredMinimum: (x) => x.ItemID, - groupedWithMinMaxThresholds: (x) => x.ItemID, - newPlanMatrixWithDisplayName: (x) => x.ItemID, - newPlanGroupedTieredPackage: (x) => x.ItemID, - newPlanMaxGroupTieredPackage: (x) => x.ItemID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ItemID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ItemID, - newPlanCumulativeGroupedBulk: (x) => x.ItemID, - cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, - newPlanMinimumComposite: (x) => x.ItemID, - percent: (x) => x.ItemID, - eventOutput: (x) => x.ItemID - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); } + init { this._rawData.Set("currency", value); } } - public string Name + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { get { - return Match( - newPlanUnit: (x) => x.Name, - newPlanTiered: (x) => x.Name, - newPlanBulk: (x) => x.Name, - bulkWithFilters: (x) => x.Name, - newPlanPackage: (x) => x.Name, - newPlanMatrix: (x) => x.Name, - newPlanThresholdTotalAmount: (x) => x.Name, - newPlanTieredPackage: (x) => x.Name, - newPlanTieredWithMinimum: (x) => x.Name, - newPlanGroupedTiered: (x) => x.Name, - newPlanTieredPackageWithMinimum: (x) => x.Name, - newPlanPackageWithAllocation: (x) => x.Name, - newPlanUnitWithPercent: (x) => x.Name, - newPlanMatrixWithAllocation: (x) => x.Name, - tieredWithProration: (x) => x.Name, - newPlanUnitWithProration: (x) => x.Name, - newPlanGroupedAllocation: (x) => x.Name, - newPlanBulkWithProration: (x) => x.Name, - newPlanGroupedWithProratedMinimum: (x) => x.Name, - newPlanGroupedWithMeteredMinimum: (x) => x.Name, - groupedWithMinMaxThresholds: (x) => x.Name, - newPlanMatrixWithDisplayName: (x) => x.Name, - newPlanGroupedTieredPackage: (x) => x.Name, - newPlanMaxGroupTieredPackage: (x) => x.Name, - newPlanScalableMatrixWithUnitPricing: (x) => x.Name, - newPlanScalableMatrixWithTieredPricing: (x) => x.Name, - newPlanCumulativeGroupedBulk: (x) => x.Name, - cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, - newPlanMinimumComposite: (x) => x.Name, - percent: (x) => x.Name, - eventOutput: (x) => x.Name + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" ); } + init { this._rawData.Set("dimensional_price_configuration", value); } } - public string? BillableMetricID + /// + /// An alias for the price. + /// + public string? ExternalPriceID { get { - return Match( - newPlanUnit: (x) => x.BillableMetricID, - newPlanTiered: (x) => x.BillableMetricID, - newPlanBulk: (x) => x.BillableMetricID, - bulkWithFilters: (x) => x.BillableMetricID, - newPlanPackage: (x) => x.BillableMetricID, - newPlanMatrix: (x) => x.BillableMetricID, - newPlanThresholdTotalAmount: (x) => x.BillableMetricID, - newPlanTieredPackage: (x) => x.BillableMetricID, - newPlanTieredWithMinimum: (x) => x.BillableMetricID, - newPlanGroupedTiered: (x) => x.BillableMetricID, - newPlanTieredPackageWithMinimum: (x) => x.BillableMetricID, - newPlanPackageWithAllocation: (x) => x.BillableMetricID, - newPlanUnitWithPercent: (x) => x.BillableMetricID, - newPlanMatrixWithAllocation: (x) => x.BillableMetricID, - tieredWithProration: (x) => x.BillableMetricID, - newPlanUnitWithProration: (x) => x.BillableMetricID, - newPlanGroupedAllocation: (x) => x.BillableMetricID, - newPlanBulkWithProration: (x) => x.BillableMetricID, - newPlanGroupedWithProratedMinimum: (x) => x.BillableMetricID, - newPlanGroupedWithMeteredMinimum: (x) => x.BillableMetricID, - groupedWithMinMaxThresholds: (x) => x.BillableMetricID, - newPlanMatrixWithDisplayName: (x) => x.BillableMetricID, - newPlanGroupedTieredPackage: (x) => x.BillableMetricID, - newPlanMaxGroupTieredPackage: (x) => x.BillableMetricID, - newPlanScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, - newPlanScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, - newPlanCumulativeGroupedBulk: (x) => x.BillableMetricID, - cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, - newPlanMinimumComposite: (x) => x.BillableMetricID, - percent: (x) => x.BillableMetricID, - eventOutput: (x) => x.BillableMetricID - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); } + init { this._rawData.Set("external_price_id", value); } } - public bool? BilledInAdvance + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity { get { - return Match( - newPlanUnit: (x) => x.BilledInAdvance, - newPlanTiered: (x) => x.BilledInAdvance, - newPlanBulk: (x) => x.BilledInAdvance, - bulkWithFilters: (x) => x.BilledInAdvance, - newPlanPackage: (x) => x.BilledInAdvance, - newPlanMatrix: (x) => x.BilledInAdvance, - newPlanThresholdTotalAmount: (x) => x.BilledInAdvance, - newPlanTieredPackage: (x) => x.BilledInAdvance, - newPlanTieredWithMinimum: (x) => x.BilledInAdvance, - newPlanGroupedTiered: (x) => x.BilledInAdvance, - newPlanTieredPackageWithMinimum: (x) => x.BilledInAdvance, - newPlanPackageWithAllocation: (x) => x.BilledInAdvance, - newPlanUnitWithPercent: (x) => x.BilledInAdvance, - newPlanMatrixWithAllocation: (x) => x.BilledInAdvance, - tieredWithProration: (x) => x.BilledInAdvance, - newPlanUnitWithProration: (x) => x.BilledInAdvance, - newPlanGroupedAllocation: (x) => x.BilledInAdvance, - newPlanBulkWithProration: (x) => x.BilledInAdvance, - newPlanGroupedWithProratedMinimum: (x) => x.BilledInAdvance, - newPlanGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, - groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, - newPlanMatrixWithDisplayName: (x) => x.BilledInAdvance, - newPlanGroupedTieredPackage: (x) => x.BilledInAdvance, - newPlanMaxGroupTieredPackage: (x) => x.BilledInAdvance, - newPlanScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, - newPlanScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, - newPlanCumulativeGroupedBulk: (x) => x.BilledInAdvance, - cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, - newPlanMinimumComposite: (x) => x.BilledInAdvance, - percent: (x) => x.BilledInAdvance, - eventOutput: (x) => x.BilledInAdvance - ); + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); } + init { this._rawData.Set("fixed_price_quantity", value); } } - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey { 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 - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); } + init { this._rawData.Set("invoice_grouping_key", value); } } - public double? ConversionRate + /// + /// 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 { - 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 + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" ); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - public string? Currency + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { 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 - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); } + init { this._rawData.Set("license_type_id", value); } } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + /// User-specified key/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 { - 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 - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); } - } - - public string? ExternalPriceID - { - get + init { - 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 + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) ); } } - public double? FixedPriceQuantity + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID { 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 - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); } + init { this._rawData.Set("reference_id", value); } } - public string? InvoiceGroupingKey + /// + public override void Validate() { - get + this.Cadence.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) { - 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 - ); + item.Validate(); } - } - - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_with_minimum") + ) + ) { - 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 - ); + 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 string? ReferenceID + public TieredWithMinimum() { - 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 - ); - } + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); } - public ReplacePricePrice(NewPlanUnitPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimum(TieredWithMinimum tieredWithMinimum) + : base(tieredWithMinimum) { } +#pragma warning restore CS8618 - public ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) + public TieredWithMinimum(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); } - public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimum(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value, - JsonElement? element = null + /// + public static TieredWithMinimum FromRawUnchecked( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public ReplacePricePrice(NewPlanPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +class TieredWithMinimumFromRaw : IFromRawJson +{ + /// + public TieredWithMinimum FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithMinimum.FromRawUnchecked(rawData); +} - public ReplacePricePrice(NewPlanMatrixPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(TieredWithMinimumCadenceConverter))] +public enum TieredWithMinimumCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} - public ReplacePricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) +sealed class TieredWithMinimumCadenceConverter : JsonConverter +{ + public override TieredWithMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - this.Value = value; - this._element = element; + 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 ReplacePricePrice(NewPlanTieredPackagePrice value, JsonElement? element = null) + public override void Write( + Utf8JsonWriter writer, + TieredWithMinimumCadence value, + JsonSerializerOptions options + ) { - this.Value = value; - this._element = element; + 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 + ); } +} - public ReplacePricePrice(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) +[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 { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } } - public ReplacePricePrice(NewPlanGroupedTieredPrice value, JsonElement? element = null) + /// + /// The currency of the license allocation. + /// + public required string Currency { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } } - public ReplacePricePrice( - NewPlanTieredPackageWithMinimumPrice value, - JsonElement? element = null - ) + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } } - public ReplacePricePrice(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public ReplacePricePrice(NewPlanUnitWithPercentPrice value, JsonElement? element = null) + public TieredWithMinimumLicenseAllocation() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumLicenseAllocation( + TieredWithMinimumLicenseAllocation tieredWithMinimumLicenseAllocation + ) + : base(tieredWithMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public TieredWithMinimumLicenseAllocation(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public ReplacePricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimumLicenseAllocation(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value, - JsonElement? element = null + /// + public static TieredWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public ReplacePricePrice(NewPlanUnitWithProrationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +class TieredWithMinimumLicenseAllocationFromRaw : IFromRawJson +{ + /// + public TieredWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithMinimumLicenseAllocation.FromRawUnchecked(rawData); +} - public ReplacePricePrice(NewPlanGroupedAllocationPrice value, JsonElement? element = null) +/// +/// 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 { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } } - public ReplacePricePrice(NewPlanBulkWithProrationPrice value, JsonElement? element = null) + /// + /// If true, tiers with an accrued amount of 0 will not be included in the rating. + /// + public bool? HideZeroAmountTiers { - this.Value = value; - this._element = element; - } + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("hide_zero_amount_tiers"); + } + init + { + if (value == null) + { + return; + } - public ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; + this._rawData.Set("hide_zero_amount_tiers", value); + } } - public ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value, - JsonElement? element = null - ) + /// + /// If true, the unit price will be prorated to the billing period + /// + public bool? Prorate { - this.Value = value; - this._element = element; - } + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("prorate"); + } + init + { + if (value == null) + { + return; + } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; + this._rawData.Set("prorate", value); + } } - public ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) + /// + public override void Validate() { - this.Value = value; - this._element = element; + foreach (var item in this.Tiers) + { + item.Validate(); + } + _ = this.HideZeroAmountTiers; + _ = this.Prorate; } - public ReplacePricePrice(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public TieredWithMinimumConfig() { } - public ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumConfig(TieredWithMinimumConfig tieredWithMinimumConfig) + : base(tieredWithMinimumConfig) { } +#pragma warning restore CS8618 + + public TieredWithMinimumConfig(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithMinimumConfig(FrozenDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null + /// + public static TieredWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - public ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) + [SetsRequiredMembers] + public TieredWithMinimumConfig(IReadOnlyList tiers) + : this() { - this.Value = value; - this._element = element; + this.Tiers = tiers; } +} - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null - ) +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 { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", value); } } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value, - JsonElement? element = null + 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 ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public ReplacePricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) +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 { - this.Value = value; - this._element = element; + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value, + public TieredWithMinimumConversionRateConfig( + SharedUnitConversionRateConfig value, JsonElement? element = null ) { @@ -11230,8 +11493,8 @@ public ReplacePricePrice( this._element = element; } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value, + public TieredWithMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, JsonElement? element = null ) { @@ -11239,752 +11502,1035 @@ public ReplacePricePrice( this._element = element; } - public ReplacePricePrice(JsonElement 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 . + /// 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 `SharedUnitConversionRateConfig` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) { - value = this.Value as NewPlanUnitPrice; + 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.TryPickNewPlanTiered(out var value)) { - /// // `value` is of type `NewPlanTieredPrice` + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) { - value = this.Value as NewPlanTieredPrice; + value = this.Value as SharedTieredConversionRateConfig; 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.TryPickNewPlanBulk(out var value)) { - /// // `value` is of type `NewPlanBulkPrice` - /// Console.WriteLine(value); - /// } + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); /// /// /// - public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) + public void Switch( + System::Action unit, + System::Action tiered + ) { - value = this.Value as NewPlanBulkPrice; - return value != null; + 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" + ); + } } /// - /// 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.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters` - /// Console.WriteLine(value); - /// } + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters? value + public T Match( + System::Func unit, + System::Func tiered ) { - value = - this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters; - return value != null; + 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); + /// - /// 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.TryPickNewPlanPackage(out var value)) { - /// // `value` is of type `NewPlanPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// + /// Thrown when the instance does not pass validation. + /// /// - public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) + public override void Validate() { - value = this.Value as NewPlanPackagePrice; - return value != null; + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of TieredWithMinimumConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.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.TryPickNewPlanMatrix(out var value)) { - /// // `value` is of type `NewPlanMatrixPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) + public virtual bool Equals(TieredWithMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() { - value = this.Value as NewPlanMatrixPrice; - 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.TryPickNewPlanThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewPlanThresholdTotalAmountPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanThresholdTotalAmount( - [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value - ) + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() { - value = this.Value as NewPlanThresholdTotalAmountPrice; - return value != null; + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; } +} - /// - /// Returns true and sets the 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 +sealed class TieredWithMinimumConversionRateConfigConverter + : JsonConverter +{ + public override TieredWithMinimumConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - value = this.Value as NewPlanTieredPackagePrice; - return value != null; + 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); + } + } } - /// - /// Returns true and sets the 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 + public override void Write( + Utf8JsonWriter writer, + TieredWithMinimumConversionRateConfig value, + JsonSerializerOptions options ) { - value = this.Value as NewPlanTieredWithMinimumPrice; - return value != null; + JsonSerializer.Serialize(writer, value.Json, options); } +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class GroupedTiered : JsonModel +{ /// - /// Returns true and sets the 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); - /// } - /// - /// + /// The cadence to bill for this price on. /// - public bool TryPickNewPlanGroupedTiered( - [NotNullWhen(true)] out NewPlanGroupedTieredPrice? value - ) + public required ApiEnum Cadence { - value = this.Value as NewPlanGroupedTieredPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>("cadence"); + } + init { this._rawData.Set("cadence", 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.TryPickNewPlanTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewPlanTieredPackageWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// Configuration for grouped_tiered pricing /// - public bool TryPickNewPlanTieredPackageWithMinimum( - [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? value - ) + public required GroupedTieredConfig GroupedTieredConfig { - value = this.Value as NewPlanTieredPackageWithMinimumPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouped_tiered_config"); + } + init { this._rawData.Set("grouped_tiered_config", 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.TryPickNewPlanPackageWithAllocation(out var value)) { - /// // `value` is of type `NewPlanPackageWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the item the price will be associated with. /// - public bool TryPickNewPlanPackageWithAllocation( - [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value - ) + public required string ItemID { - value = this.Value as NewPlanPackageWithAllocationPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", 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.TryPickNewPlanUnitWithPercent(out var value)) { - /// // `value` is of type `NewPlanUnitWithPercentPrice` - /// Console.WriteLine(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 bool TryPickNewPlanUnitWithPercent( - [NotNullWhen(true)] out NewPlanUnitWithPercentPrice? value - ) + public required IReadOnlyList LicenseAllocations { - value = this.Value as NewPlanUnitWithPercentPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "license_allocations" + ); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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.TryPickNewPlanMatrixWithAllocation(out var value)) { - /// // `value` is of type `NewPlanMatrixWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The pricing model type /// - public bool TryPickNewPlanMatrixWithAllocation( - [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value - ) + public JsonElement ModelType { - value = this.Value as NewPlanMatrixWithAllocationPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", 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.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration` - /// Console.WriteLine(value); - /// } - /// - /// + /// The name of the price. /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration? value - ) + public required string Name { - value = - this.Value - as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", 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.TryPickNewPlanUnitWithProration(out var value)) { - /// // `value` is of type `NewPlanUnitWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. /// - public bool TryPickNewPlanUnitWithProration( - [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value - ) + public string? BillableMetricID { - value = this.Value as NewPlanUnitWithProrationPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", 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.TryPickNewPlanGroupedAllocation(out var value)) { - /// // `value` is of type `NewPlanGroupedAllocationPrice` - /// Console.WriteLine(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 TryPickNewPlanGroupedAllocation( - [NotNullWhen(true)] out NewPlanGroupedAllocationPrice? value - ) + public bool? BilledInAdvance { - value = this.Value as NewPlanGroupedAllocationPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", 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.TryPickNewPlanBulkWithProration(out var value)) { - /// // `value` is of type `NewPlanBulkWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. /// - public bool TryPickNewPlanBulkWithProration( - [NotNullWhen(true)] out NewPlanBulkWithProrationPrice? value - ) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - value = this.Value as NewPlanBulkWithProrationPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", 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.TryPickNewPlanGroupedWithProratedMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithProratedMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The per unit conversion rate of the price currency to the invoicing currency. /// - public bool TryPickNewPlanGroupedWithProratedMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithProratedMinimumPrice? value - ) + public double? ConversionRate { - value = this.Value as NewPlanGroupedWithProratedMinimumPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", 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.TryPickNewPlanGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewPlanGroupedWithMeteredMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The configuration for the rate of the price currency to the invoicing currency. /// - public bool TryPickNewPlanGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value - ) + public GroupedTieredConversionRateConfig? ConversionRateConfig { - value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds? value - ) + public string? Currency { - value = - this.Value - as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// For dimensional price: specifies a price group and dimension values /// - public bool TryPickNewPlanMatrixWithDisplayName( - [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value - ) + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - value = this.Value as NewPlanMatrixWithDisplayNamePrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", 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.TryPickNewPlanGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// An alias for the price. /// - public bool TryPickNewPlanGroupedTieredPackage( - [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value - ) + public string? ExternalPriceID { - value = this.Value as NewPlanGroupedTieredPackagePrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", 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.TryPickNewPlanMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. /// - public bool TryPickNewPlanMaxGroupTieredPackage( - [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? value - ) + public double? FixedPriceQuantity { - value = this.Value as NewPlanMaxGroupTieredPackagePrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", 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.TryPickNewPlanScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithUnitPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The property used to group this price on an invoice /// - public bool TryPickNewPlanScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithUnitPricingPrice? value - ) + public string? InvoiceGroupingKey { - value = this.Value as NewPlanScalableMatrixWithUnitPricingPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", 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.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. /// - public bool TryPickNewPlanScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value - ) + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", 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.TryPickNewPlanCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The ID of the license type to associate with this price. /// - public bool TryPickNewPlanCumulativeGroupedBulk( - [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value - ) + public string? LicenseTypeID { - value = this.Value as NewPlanCumulativeGroupedBulkPrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", 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 `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// + /// User-specified key/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 bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation? value - ) + public IReadOnlyDictionary? Metadata { - value = - this.Value - as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(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 `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. /// - public bool TryPickMinimum( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum? value - ) + public string? ReferenceID { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); + } + init { this._rawData.Set("reference_id", 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.TryPickNewPlanMinimumComposite(out var value)) { - /// // `value` is of type `NewPlanMinimumCompositePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMinimumComposite( - [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value - ) + /// + public override void Validate() { - value = this.Value as NewPlanMinimumCompositePrice; - return value != null; + 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; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickPercent(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickPercent( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent? value - ) + public GroupedTiered() { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent; - return value != null; + this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered"); } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickEventOutput(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickEventOutput( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput? value +#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 ) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput; - return value != null; + 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 @@ -11998,178 +12544,28 @@ public bool TryPickEventOutput( /// /// /// instance.Switch( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, - /// (NewPlanGroupedTieredPackagePrice value) => {...}, - /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, - /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig 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 + System::Action unit, + System::Action tiered ) { switch (this.Value) { - case NewPlanUnitPrice value: - newPlanUnit(value); - break; - case NewPlanTieredPrice value: - newPlanTiered(value); - break; - case NewPlanBulkPrice value: - newPlanBulk(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value: - bulkWithFilters(value); - break; - case NewPlanPackagePrice value: - newPlanPackage(value); - break; - case NewPlanMatrixPrice value: - newPlanMatrix(value); - break; - case NewPlanThresholdTotalAmountPrice value: - newPlanThresholdTotalAmount(value); - break; - case NewPlanTieredPackagePrice value: - newPlanTieredPackage(value); - break; - case NewPlanTieredWithMinimumPrice value: - newPlanTieredWithMinimum(value); - break; - case NewPlanGroupedTieredPrice value: - newPlanGroupedTiered(value); - break; - case NewPlanTieredPackageWithMinimumPrice value: - newPlanTieredPackageWithMinimum(value); - break; - case NewPlanPackageWithAllocationPrice value: - newPlanPackageWithAllocation(value); - break; - case NewPlanUnitWithPercentPrice value: - newPlanUnitWithPercent(value); - break; - case NewPlanMatrixWithAllocationPrice value: - newPlanMatrixWithAllocation(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value: - tieredWithProration(value); - break; - case NewPlanUnitWithProrationPrice value: - newPlanUnitWithProration(value); - break; - case NewPlanGroupedAllocationPrice value: - newPlanGroupedAllocation(value); - break; - case NewPlanBulkWithProrationPrice value: - newPlanBulkWithProration(value); - break; - case NewPlanGroupedWithProratedMinimumPrice value: - newPlanGroupedWithProratedMinimum(value); - break; - case NewPlanGroupedWithMeteredMinimumPrice value: - newPlanGroupedWithMeteredMinimum(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value: - groupedWithMinMaxThresholds(value); - break; - case NewPlanMatrixWithDisplayNamePrice value: - newPlanMatrixWithDisplayName(value); - break; - case NewPlanGroupedTieredPackagePrice value: - newPlanGroupedTieredPackage(value); - break; - case NewPlanMaxGroupTieredPackagePrice value: - newPlanMaxGroupTieredPackage(value); - break; - case NewPlanScalableMatrixWithUnitPricingPrice value: - newPlanScalableMatrixWithUnitPricing(value); - break; - case NewPlanScalableMatrixWithTieredPricingPrice value: - newPlanScalableMatrixWithTieredPricing(value); - break; - case NewPlanCumulativeGroupedBulkPrice value: - newPlanCumulativeGroupedBulk(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value: - cumulativeGroupedAllocation(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value: - minimum(value); - break; - case NewPlanMinimumCompositePrice value: - newPlanMinimumComposite(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value: - percent(value); + case SharedUnitConversionRateConfig value: + unit(value); break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value: - eventOutput(value); + case SharedTieredConversionRateConfig value: + tiered(value); break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" + "Data did not match any variant of GroupedTieredConversionRateConfig" ); } } @@ -12189,274 +12585,33 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, - /// (NewPlanGroupedTieredPackagePrice value) => {...}, - /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, - /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// /// public T Match( - System::Func newPlanUnit, - System::Func newPlanTiered, - System::Func newPlanBulk, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters, - T - > bulkWithFilters, - System::Func newPlanPackage, - System::Func newPlanMatrix, - System::Func newPlanThresholdTotalAmount, - System::Func newPlanTieredPackage, - System::Func newPlanTieredWithMinimum, - System::Func newPlanGroupedTiered, - System::Func newPlanTieredPackageWithMinimum, - System::Func newPlanPackageWithAllocation, - System::Func newPlanUnitWithPercent, - System::Func newPlanMatrixWithAllocation, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration, - T - > tieredWithProration, - System::Func newPlanUnitWithProration, - System::Func newPlanGroupedAllocation, - System::Func newPlanBulkWithProration, - System::Func newPlanGroupedWithProratedMinimum, - System::Func newPlanGroupedWithMeteredMinimum, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds, - T - > groupedWithMinMaxThresholds, - System::Func newPlanMatrixWithDisplayName, - System::Func newPlanGroupedTieredPackage, - System::Func newPlanMaxGroupTieredPackage, - System::Func< - NewPlanScalableMatrixWithUnitPricingPrice, - T - > newPlanScalableMatrixWithUnitPricing, - System::Func< - NewPlanScalableMatrixWithTieredPricingPrice, - T - > newPlanScalableMatrixWithTieredPricing, - System::Func newPlanCumulativeGroupedBulk, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, - System::Func newPlanMinimumComposite, - System::Func percent, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput, - T - > eventOutput + System::Func unit, + System::Func tiered ) { return this.Value switch { - NewPlanUnitPrice value => newPlanUnit(value), - NewPlanTieredPrice value => newPlanTiered(value), - NewPlanBulkPrice value => newPlanBulk(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value => - bulkWithFilters(value), - NewPlanPackagePrice value => newPlanPackage(value), - NewPlanMatrixPrice value => newPlanMatrix(value), - NewPlanThresholdTotalAmountPrice value => newPlanThresholdTotalAmount(value), - NewPlanTieredPackagePrice value => newPlanTieredPackage(value), - NewPlanTieredWithMinimumPrice value => newPlanTieredWithMinimum(value), - NewPlanGroupedTieredPrice value => newPlanGroupedTiered(value), - NewPlanTieredPackageWithMinimumPrice value => newPlanTieredPackageWithMinimum(value), - NewPlanPackageWithAllocationPrice value => newPlanPackageWithAllocation(value), - NewPlanUnitWithPercentPrice value => newPlanUnitWithPercent(value), - NewPlanMatrixWithAllocationPrice value => newPlanMatrixWithAllocation(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value => - tieredWithProration(value), - NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), - NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), - NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), - NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( - value - ), - NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value => - groupedWithMinMaxThresholds(value), - NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), - NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), - NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), - NewPlanScalableMatrixWithUnitPricingPrice value => newPlanScalableMatrixWithUnitPricing( - value - ), - NewPlanScalableMatrixWithTieredPricingPrice value => - newPlanScalableMatrixWithTieredPricing(value), - NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value => - cumulativeGroupedAllocation(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value => minimum(value), - NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value => percent(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value => - eventOutput(value), + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" + "Data did not match any variant of GroupedTieredConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanUnitPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanBulkPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanPackagePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMatrixPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanThresholdTotalAmountPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredPackagePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredWithMinimumPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedTieredPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredPackageWithMinimumPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanPackageWithAllocationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanUnitWithPercentPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMatrixWithAllocationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanUnitWithProrationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedAllocationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanBulkWithProrationPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMatrixWithDisplayNamePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedTieredPackagePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMaxGroupTieredPackagePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanCumulativeGroupedBulkPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMinimumCompositePrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value + public static implicit operator GroupedTieredConversionRateConfig( + SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value + public static implicit operator GroupedTieredConversionRateConfig( + SharedTieredConversionRateConfig value ) => new(value); /// @@ -12474,51 +12629,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" + "Data did not match any variant of GroupedTieredConversionRateConfig" ); } - 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() - ); + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? 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() { @@ -12526,36 +12646,49 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplacePricePriceConverter - : JsonConverter +sealed class GroupedTieredConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? Read( + public override GroupedTieredConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; + string? conversionRateType; try { - modelType = element.GetProperty("model_type").GetString(); + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); } catch { - modelType = null; + conversionRateType = null; } - switch (modelType) + switch (conversionRateType) { case "unit": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -12577,7 +12710,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -12595,935 +12728,286 @@ JsonSerializerOptions options return new(element); } - case "bulk": + default: { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); + return new GroupedTieredConversionRateConfig(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 - } + public override void Write( + Utf8JsonWriter writer, + GroupedTieredConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} - 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 - } +[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); } + } - 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 - } + /// + /// 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); } + } - 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 - } + /// + /// 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) + ); + } + } - 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 pricing model type + /// + public JsonElement ModelType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } + } - 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 - } + /// + /// The name of the price. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } - 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 - } + /// + /// 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); } + } - 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 - } + /// + /// 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); } + } - 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 - } + /// + /// 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); } + } - return new(element); - } - case "matrix_with_allocation": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "unit_with_proration": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_allocation": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_prorated_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_metered_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix_with_display_name": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_tiered_package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "max_group_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_unit_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_tiered_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_bulk": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum_composite": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "percent": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "event_output": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value?.Json, options); - } -} - -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFilters : JsonModel -{ /// - /// Configuration for bulk_with_filters pricing + /// For custom cadence: specifies the duration of the billing period in days + /// or months. /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig + public NewBillingCycleConfiguration? BillingCycleConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" + return this._rawData.GetNullableClass( + "billing_cycle_configuration" ); } - init { this._rawData.Set("bulk_with_filters_config", value); } + init { this._rawData.Set("billing_cycle_configuration", value); } } /// - /// The cadence to bill for this price on. + /// The per unit conversion rate of the price currency to the invoicing currency. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence - > Cadence + public double? ConversionRate { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence - > - >("cadence"); + return this._rawData.GetNullableStruct("conversion_rate"); } - init { this._rawData.Set("cadence", value); } + init { this._rawData.Set("conversion_rate", value); } } /// - /// The id of the item the price will be associated with. + /// The configuration for the rate of the price currency to the invoicing currency. /// - public required string ItemID + public TieredPackageWithMinimumConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("conversion_rate_config", value); } } /// - /// The pricing model type + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. /// - public JsonElement ModelType + public string? Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNullableClass("currency"); } - init { this._rawData.Set("model_type", value); } + init { this._rawData.Set("currency", value); } } /// - /// The name of the price. + /// For dimensional price: specifies a price group and dimension values /// - public required string Name + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("dimensional_price_configuration", value); } } /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// An alias for the price. /// - public string? BillableMetricID + public string? ExternalPriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); + return this._rawData.GetNullableClass("external_price_id"); } - init { this._rawData.Set("billable_metric_id", value); } + init { this._rawData.Set("external_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. + /// If the Price represents a fixed cost, this represents the quantity of units applied. /// - public bool? BilledInAdvance + public double? FixedPriceQuantity { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); + return this._rawData.GetNullableStruct("fixed_price_quantity"); } - init { this._rawData.Set("billed_in_advance", value); } + init { this._rawData.Set("fixed_price_quantity", value); } } /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. + /// The property used to group this price on an invoice /// - public NewBillingCycleConfiguration? BillingCycleConfiguration + public string? InvoiceGroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); + return this._rawData.GetNullableClass("invoice_grouping_key"); } - init { this._rawData.Set("billing_cycle_configuration", value); } + init { this._rawData.Set("invoice_grouping_key", value); } } /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } - } - - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } - - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); - } - init { this._rawData.Set("currency", value); } - } - - /// - /// For dimensional price: specifies a price group and dimension values + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" + return this._rawData.GetNullableClass( + "invoicing_cycle_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); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. + /// The ID of the license type to associate with this price. /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + public string? LicenseTypeID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); + return this._rawData.GetNullableClass("license_type_id"); } - init { this._rawData.Set("invoicing_cycle_configuration", value); } + init { this._rawData.Set("license_type_id", value); } } /// @@ -13564,19 +13048,23 @@ public string? ReferenceID /// 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") + 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(); @@ -13588,37 +13076,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceBulkWithFilters() + public TieredPackageWithMinimum() { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_package_with_minimum"); } - public ReplacePricePriceBulkWithFilters( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters - ) - : base(replacePricePriceBulkWithFilters) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimum(TieredPackageWithMinimum tieredPackageWithMinimum) + : base(tieredPackageWithMinimum) { } +#pragma warning restore CS8618 - public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) + public TieredPackageWithMinimum(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_package_with_minimum"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) + TieredPackageWithMinimum(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters FromRawUnchecked( + /// + public static TieredPackageWithMinimum FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -13626,90 +13116,140 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceBulkWithFiltersFromRaw - : IFromRawJson +class TieredPackageWithMinimumFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters FromRawUnchecked( + public TieredPackageWithMinimum FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters.FromRawUnchecked( - rawData - ); + ) => TieredPackageWithMinimum.FromRawUnchecked(rawData); } /// -/// Configuration for bulk_with_filters pricing +/// 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< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + TieredPackageWithMinimumLicenseAllocation, + TieredPackageWithMinimumLicenseAllocationFromRaw >) )] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel +public sealed record class TieredPackageWithMinimumLicenseAllocation : JsonModel { /// - /// Property filters to apply (all must match) + /// The amount of credits granted per active license per cadence. /// - public required IReadOnlyList Filters + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("filters"); - } - init - { - this._rawData.Set< - ImmutableArray - >("filters", ImmutableArray.ToImmutableArray(value)); + return this._rawData.GetNotNullClass("amount"); } + init { this._rawData.Set("amount", value); } } /// - /// Bulk tiers for rating based on total usage volume + /// The currency of the license allocation. /// - public required IReadOnlyList Tiers + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullClass("currency"); } - init + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) - { - item.Validate(); - } + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } + public TieredPackageWithMinimumLicenseAllocation() { } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimumLicenseAllocation( + TieredPackageWithMinimumLicenseAllocation tieredPackageWithMinimumLicenseAllocation ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } + : base(tieredPackageWithMinimumLicenseAllocation) { } +#pragma warning restore CS8618 - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + public TieredPackageWithMinimumLicenseAllocation( IReadOnlyDictionary rawData ) { @@ -13718,16 +13258,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - FrozenDictionary rawData - ) + TieredPackageWithMinimumLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + /// + public static TieredPackageWithMinimumLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -13735,88 +13273,93 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - : IFromRawJson +class TieredPackageWithMinimumLicenseAllocationFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + public TieredPackageWithMinimumLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked( - rawData - ); + ) => TieredPackageWithMinimumLicenseAllocation.FromRawUnchecked(rawData); } /// -/// Configuration for a single property filter +/// Configuration for tiered_package_with_minimum pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + TieredPackageWithMinimumConfig, + TieredPackageWithMinimumConfigFromRaw >) )] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel +public sealed record class TieredPackageWithMinimumConfig : JsonModel { - /// - /// Event property key to filter on - /// - public required string PropertyKey + public required double PackageSize { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_key"); + return this._rawData.GetNotNullStruct("package_size"); } - init { this._rawData.Set("property_key", value); } + init { this._rawData.Set("package_size", value); } } /// - /// Event property value to match + /// Apply tiered pricing after rounding up the quantity to the package size. + /// Tiers are defined using exclusive lower bounds. /// - public required string PropertyValue + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("property_value", value); } } /// public override void Validate() { - _ = this.PropertyKey; - _ = this.PropertyValue; + _ = this.PackageSize; + foreach (var item in this.Tiers) + { + item.Validate(); + } } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } + public TieredPackageWithMinimumConfig() { } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimumConfig( + TieredPackageWithMinimumConfig tieredPackageWithMinimumConfig ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } + : base(tieredPackageWithMinimumConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - IReadOnlyDictionary rawData - ) + public TieredPackageWithMinimumConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - FrozenDictionary rawData - ) + TieredPackageWithMinimumConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + /// + public static TieredPackageWithMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -13824,51 +13367,51 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - : IFromRawJson +class TieredPackageWithMinimumConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + public TieredPackageWithMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked( - rawData - ); + ) => TieredPackageWithMinimumConfig.FromRawUnchecked(rawData); } /// -/// Configuration for a single bulk pricing tier +/// Configuration for a single tier /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + TieredPackageWithMinimumConfigTier, + TieredPackageWithMinimumConfigTierFromRaw >) )] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel +public sealed record class TieredPackageWithMinimumConfigTier : JsonModel { - /// - /// Amount per unit - /// - public required string UnitAmount + public required string MinimumAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("minimum_amount"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("minimum_amount", value); } } - /// - /// The lower bound for this tier - /// - public string? TierLowerBound + public required string PerUnit { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); + 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); } } @@ -13876,190 +13419,53 @@ public string? TierLowerBound /// public override void Validate() { - _ = this.UnitAmount; + _ = this.MinimumAmount; + _ = this.PerUnit; _ = this.TierLowerBound; } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } + public TieredPackageWithMinimumConfigTier() { } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageWithMinimumConfigTier( + TieredPackageWithMinimumConfigTier tieredPackageWithMinimumConfigTier ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } + : base(tieredPackageWithMinimumConfigTier) { } +#pragma warning restore CS8618 - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - IReadOnlyDictionary rawData - ) + public TieredPackageWithMinimumConfigTier(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - FrozenDictionary rawData - ) + TieredPackageWithMinimumConfigTier(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + /// + public static TieredPackageWithMinimumConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - : IFromRawJson +class TieredPackageWithMinimumConfigTierFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + public TieredPackageWithMinimumConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked( - rawData - ); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadenceConverter) -)] -public enum ReplacePricePriceBulkWithFiltersCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class ReplacePricePriceBulkWithFiltersCadenceConverter - : JsonConverter -{ - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .OneTime, - "custom" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceBulkWithFiltersCadence - .Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence)( - -1 - ), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - 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", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } + ) => TieredPackageWithMinimumConfigTier.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfigConverter) -)] -public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase +[JsonConverter(typeof(TieredPackageWithMinimumConversionRateConfigConverter))] +public record class TieredPackageWithMinimumConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -14076,7 +13482,7 @@ public JsonElement Json } } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( + public TieredPackageWithMinimumConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -14085,7 +13491,7 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig( this._element = element; } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( + public TieredPackageWithMinimumConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -14094,201 +13500,65250 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig( this._element = element; } - public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) - { - 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); + } +} + +/// +/// 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 + { + 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 ReplacePricePrice(NewPlanUnitPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) + { + 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(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; + } + + /// + /// Returns true and sets the 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 `ReplacePricePriceBulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters( + [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value + ) + { + value = this.Value as ReplacePricePriceBulkWithFilters; + return value != null; + } + + /// + /// Returns true and sets the 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 `ReplacePricePriceTieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration( + [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value + ) + { + value = this.Value as ReplacePricePriceTieredWithProration; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// 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 `ReplacePricePriceGroupedWithMinMaxThresholds` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value + ) + { + value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// 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 `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.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) => {...}, + /// (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 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 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) => {...}, + /// (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 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 + ), + NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), + ReplacePricePricePercent value => percent(value), + ReplacePricePriceEventOutput value => eventOutput(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePrice" + ), + }; + } + + public static implicit operator ReplacePricePrice(NewPlanUnitPrice value) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanTieredPrice value) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanBulkPrice value) => new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePriceBulkWithFilters value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanPackagePrice value) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanMatrixPrice value) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanThresholdTotalAmountPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanTieredPackagePrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanTieredWithMinimumPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanTieredPackageWithMinimumPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanPackageWithAllocationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanUnitWithPercentPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanMatrixWithAllocationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePriceTieredWithProration value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanUnitWithProrationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanGroupedAllocationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanBulkWithProrationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice( + NewPlanGroupedWithProratedMinimumPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewPlanGroupedWithMeteredMinimumPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds value + ) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPackagePrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value) => + new(value); + + public static implicit operator ReplacePricePrice( + NewPlanScalableMatrixWithUnitPricingPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewPlanScalableMatrixWithTieredPricingPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value) => + new(value); + + public static implicit operator ReplacePricePrice( + ReplacePricePriceCumulativeGroupedAllocation value + ) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanMinimumCompositePrice value) => + new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePricePercent value) => new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePriceEventOutput value) => + new(value); + + /// + /// 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(), + (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), + (percent) => percent.Validate(), + (eventOutput) => eventOutput.Validate() + ); + } + + public virtual bool Equals(ReplacePricePrice? 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, + 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 +{ + 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 + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) - { - value = this.Value as SharedUnitConversionRateConfig; - return value != null; - } + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) - { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; - } + return new(element); + } + case "grouped_with_prorated_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.Value) - { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - } + return new(element); + } + case "grouped_with_metered_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) - { - return this.Value switch - { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of 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 + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + return new(element); + } + case "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } + return new(element); + } + case "max_group_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + return new(element); + } + case "scalable_matrix_with_unit_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override int GetHashCode() - { - return 0; - } + return new(element); + } + case "scalable_matrix_with_tiered_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + return new(element); + } + case "cumulative_grouped_bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter - : JsonConverter -{ - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } + return new(element); + } + case "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 + } - switch (conversionRateType) - { - case "unit": + return new(element); + } + case "minimum_composite": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -14306,11 +78761,33 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "percent": { 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 "event_output": + { + try + { + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -14330,47 +78807,54 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig( - element - ); + return new ReplacePricePrice(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig value, + ReplacePricePrice? value, JsonSerializerOptions options ) { - JsonSerializer.Serialize(writer, value.Json, options); + JsonSerializer.Serialize(writer, value?.Json, options); } } [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationFromRaw + ReplacePricePriceBulkWithFilters, + ReplacePricePriceBulkWithFiltersFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProration : JsonModel +public sealed record class ReplacePricePriceBulkWithFilters : JsonModel { + /// + /// Configuration for bulk_with_filters pricing + /// + public required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_filters_config" + ); + } + init { this._rawData.Set("bulk_with_filters_config", value); } + } + /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadence - > + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -14415,21 +78899,6 @@ public required string Name init { this._rawData.Set("name", value); } } - /// - /// Configuration for tiered_with_proration pricing - /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "tiered_with_proration_config" - ); - } - 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. /// @@ -14489,12 +78958,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig + public ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -14585,6 +79054,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 @@ -14623,19 +79105,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(); @@ -14647,37 +79129,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceTieredWithProration() + public ReplacePricePriceBulkWithFilters() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public ReplacePricePriceTieredWithProration( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFilters( + ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters ) - : base(replacePricePriceTieredWithProration) { } + : base(replacePricePriceBulkWithFilters) { } +#pragma warning restore CS8618 - public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) + public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProration(FrozenDictionary rawData) + ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFilters FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -14685,171 +79171,61 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceTieredWithProrationFromRaw - : IFromRawJson +class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration FromRawUnchecked( + public ReplacePricePriceBulkWithFilters FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); } /// -/// The cadence to bill for this price on. +/// Configuration for bulk_with_filters pricing /// [JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadenceConverter) + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) )] -public enum ReplacePricePriceTieredWithProrationCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class ReplacePricePriceTieredWithProrationCadenceConverter - : JsonConverter +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + /// Property filters to apply (all must match) + /// + public required IReadOnlyList Filters { - return JsonSerializer.Deserialize(ref reader, options) switch + get { - "annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .OneTime, - "custom" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Custom, - _ => - (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadence)( - -1 - ), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Annual => "annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .SemiAnnual => "semi_annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Monthly => "monthly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Quarterly => "quarterly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .OneTime => "one_time", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceTieredWithProrationCadence - .Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("filters"); + } + init + { + this._rawData.Set< + ImmutableArray + >("filters", ImmutableArray.ToImmutableArray(value)); + } } -} -/// -/// Configuration for tiered_with_proration pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw - >) -)] -public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel -{ /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration + /// Bulk tiers for rating based on total usage volume /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); return this._rawData.GetNotNullStruct< - ImmutableArray + ImmutableArray >("tiers"); } init { this._rawData.Set< - ImmutableArray + ImmutableArray >("tiers", ImmutableArray.ToImmutableArray(value)); } } @@ -14857,20 +79233,27 @@ public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrati /// public override void Validate() { + foreach (var item in this.Filters) + { + item.Validate(); + } foreach (var item in this.Tiers) { item.Validate(); } } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( IReadOnlyDictionary rawData ) { @@ -14879,7 +79262,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( FrozenDictionary rawData ) { @@ -14887,89 +79270,168 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} + +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single property filter +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel +{ + /// + /// Event property key to filter on + /// + public required string PropertyKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_key"); + } + init { this._rawData.Set("property_key", value); } + } + + /// + /// Event property value to match + /// + public required string PropertyValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_value"); + } + init { this._rawData.Set("property_value", value); } + } + /// + public override void Validate() + { + _ = this.PropertyKey; + _ = this.PropertyValue; + } + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } + +#pragma warning disable CS8618 [SetsRequiredMembers] - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( - IReadOnlyList tiers + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + ) + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + IReadOnlyDictionary rawData ) - : this() { - this.Tiers = tiers; + 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 ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw - : IFromRawJson +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); } /// -/// Configuration for a single tiered with proration tier +/// Configuration for a single bulk pricing tier /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier - : JsonModel +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel { /// - /// Inclusive tier starting value + /// Amount per unit /// - public required string TierLowerBound + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("tier_lower_bound", value); } + init { this._rawData.Set("unit_amount", value); } } /// - /// Amount per unit + /// The lower bound for this tier /// - public required string UnitAmount + public string? TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNullableClass("tier_lower_bound"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// public override void Validate() { - _ = this.TierLowerBound; _ = this.UnitAmount; + _ = this.TierLowerBound; } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( IReadOnlyDictionary rawData ) { @@ -14978,7 +79440,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( FrozenDictionary rawData ) { @@ -14986,31 +79448,93 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } } -class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw - : IFromRawJson +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked( - 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 ); + } } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfigConverter) -)] -public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] +public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -15027,7 +79551,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15036,7 +79560,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15045,7 +79569,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -15127,7 +79651,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" ); } } @@ -15163,16 +79687,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -15191,18 +79715,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig? other - ) - { - 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() { @@ -15210,13 +79732,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig? Read( + public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15281,16 +79816,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig( - element - ); + return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig value, + ReplacePricePriceBulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -15300,48 +79833,27 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + ReplacePricePriceTieredWithProration, + ReplacePricePriceTieredWithProrationFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : JsonModel +public sealed record class ReplacePricePriceTieredWithProration : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsCadence - > + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } - /// - /// Configuration for grouped_with_min_max_thresholds pricing - /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); - } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } - } - /// /// The id of the item the price will be associated with. /// @@ -15381,6 +79893,21 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for tiered_with_proration pricing + /// + public required ReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_proration_config" + ); + } + init { this._rawData.Set("tiered_with_proration_config", value); } + } + /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -15440,12 +79967,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public ReplacePricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -15536,6 +80063,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 @@ -15575,18 +80115,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(); @@ -15598,39 +80138,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceGroupedWithMinMaxThresholds() + public ReplacePricePriceTieredWithProration() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public ReplacePricePriceGroupedWithMinMaxThresholds( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProration( + ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration ) - : base(replacePricePriceGroupedWithMinMaxThresholds) { } + : base(replacePricePriceTieredWithProration) { } +#pragma warning restore CS8618 - public ReplacePricePriceGroupedWithMinMaxThresholds( - IReadOnlyDictionary rawData - ) + public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) + ReplacePricePriceTieredWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15638,25 +80180,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceTieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter) -)] -public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationCadenceConverter))] +public enum ReplacePricePriceTieredWithProrationCadence { Annual, SemiAnnual, @@ -15666,10 +80203,10 @@ public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence Custom, } -sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class ReplacePricePriceTieredWithProrationCadenceConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( + public override ReplacePricePriceTieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15677,52 +80214,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .OneTime, - "custom" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .Custom, - _ => - (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsCadence)( - -1 - ), + "annual" => ReplacePricePriceTieredWithProrationCadence.Annual, + "semi_annual" => ReplacePricePriceTieredWithProrationCadence.SemiAnnual, + "monthly" => ReplacePricePriceTieredWithProrationCadence.Monthly, + "quarterly" => ReplacePricePriceTieredWithProrationCadence.Quarterly, + "one_time" => ReplacePricePriceTieredWithProrationCadence.OneTime, + "custom" => ReplacePricePriceTieredWithProrationCadence.Custom, + _ => (ReplacePricePriceTieredWithProrationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, + ReplacePricePriceTieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -15730,42 +80234,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .Annual => "annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .SemiAnnual => "semi_annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .Monthly => "monthly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .Quarterly => "quarterly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .OneTime => "one_time", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceGroupedWithMinMaxThresholdsCadence - .Custom => "custom", + ReplacePricePriceTieredWithProrationCadence.Annual => "annual", + ReplacePricePriceTieredWithProrationCadence.SemiAnnual => "semi_annual", + ReplacePricePriceTieredWithProrationCadence.Monthly => "monthly", + ReplacePricePriceTieredWithProrationCadence.Quarterly => "quarterly", + ReplacePricePriceTieredWithProrationCadence.OneTime => "one_time", + ReplacePricePriceTieredWithProrationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -15776,86 +80250,156 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for tiered_with_proration pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + ReplacePricePriceTieredWithProrationTieredWithProrationConfig, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - : JsonModel +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration /// - public required string GroupingKey + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); } - init { this._rawData.Set("grouping_key", value); } } - /// - /// The maximum amount to charge each group - /// - public required string MaximumCharge + /// + public override void Validate() { - get + foreach (var item in this.Tiers) { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + item.Validate(); } - init { this._rawData.Set("maximum_charge", value); } } + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig + ) + : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 + + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } +} + +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tiered with proration tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + >) +)] +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + : JsonModel +{ /// - /// The minimum amount to charge each group, regardless of usage + /// Inclusive tier starting value /// - public required string MinimumCharge + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// - /// The base price charged per group + /// Amount per unit /// - public required string PerUnitRate + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("per_unit_rate", value); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.TierLowerBound; + _ = this.UnitAmount; } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier ) - : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } + : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } +#pragma warning restore CS8618 - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData ) { @@ -15864,7 +80408,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -15872,8 +80416,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15881,22 +80425,18 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( - rawData - ); + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] -public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationConversionRateConfigConverter))] +public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -15913,7 +80453,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15922,7 +80462,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15931,7 +80471,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -16013,7 +80553,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ); } } @@ -16049,16 +80589,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16077,18 +80617,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other - ) - { - 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() { @@ -16096,13 +80634,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override ReplacePricePriceTieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16167,16 +80718,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + ReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -16186,46 +80735,40 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationFromRaw + ReplacePricePriceGroupedWithMinMaxThresholds, + ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonModel +public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadence - > + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// Configuration for cumulative_grouped_allocation pricing + /// Configuration for grouped_with_min_max_thresholds pricing /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" + return this._rawData.GetNotNullClass( + "grouped_with_min_max_thresholds_config" ); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } } /// @@ -16326,12 +80869,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -16422,6 +80965,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 @@ -16461,12 +81017,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") ) ) { @@ -16484,39 +81040,43 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceCumulativeGroupedAllocation() + public ReplacePricePriceGroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public ReplacePricePriceCumulativeGroupedAllocation( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceGroupedWithMinMaxThresholds( + ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds ) - : base(replacePricePriceCumulativeGroupedAllocation) { } + : base(replacePricePriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 - public ReplacePricePriceCumulativeGroupedAllocation( + public ReplacePricePriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) + ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16524,25 +81084,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked( - rawData - ); + ) => ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadenceConverter) -)] -public enum ReplacePricePriceCumulativeGroupedAllocationCadence +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter))] +public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -16552,10 +81107,10 @@ public enum ReplacePricePriceCumulativeGroupedAllocationCadence Custom, } -sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadence Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16563,52 +81118,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .OneTime, - "custom" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .Custom, - _ => - (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadence)( - -1 - ), + "annual" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom, + _ => (ReplacePricePriceGroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCadence value, + ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -16616,42 +81138,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .Annual => "annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .SemiAnnual => "semi_annual", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .Monthly => "monthly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .Quarterly => "quarterly", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .OneTime => "one_time", - global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceCumulativeGroupedAllocationCadence - .Custom => "custom", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -16662,86 +81154,89 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig : JsonModel { /// - /// The overall allocation across all groups + /// The event property used to group before applying thresholds /// - public required string CumulativeAllocation + public required string GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("cumulative_allocation"); + return this._rawData.GetNotNullClass("grouping_key"); } - init { this._rawData.Set("cumulative_allocation", value); } + init { this._rawData.Set("grouping_key", value); } } /// - /// The allocation per individual group + /// The maximum amount to charge each group /// - public required string GroupAllocation + public required string MaximumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNotNullClass("maximum_charge"); } - init { this._rawData.Set("group_allocation", value); } + init { this._rawData.Set("maximum_charge", value); } } /// - /// The event property used to group usage before applying allocations + /// The minimum amount to charge each group, regardless of usage /// - public required string GroupingKey + public required string MinimumCharge { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullClass("minimum_charge"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("minimum_charge", value); } } /// - /// The amount to charge for each unit outside of the allocation + /// The base price charged per group /// - public required string UnitAmount + public required string PerUnitRate { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullClass("per_unit_rate"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("per_unit_rate", value); } } /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; _ = this.GroupingKey; - _ = this.UnitAmount; + _ = this.MaximumCharge; + _ = this.MinimumCharge; + _ = this.PerUnitRate; } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) - : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } + : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData ) { @@ -16750,7 +81245,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -16758,8 +81253,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16767,22 +81262,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( rawData ); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter) -)] -public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -16799,7 +81292,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16808,7 +81301,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16817,7 +81310,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -16899,7 +81392,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -16935,16 +81428,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16963,18 +81456,18 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -16982,13 +81475,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17053,7 +81559,7 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -17062,7 +81568,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -17072,59 +81578,53 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumFromRaw + ReplacePricePriceCumulativeGroupedAllocation, + ReplacePricePriceCumulativeGroupedAllocationFromRaw >) )] -public sealed record class ReplacePricePriceMinimum : JsonModel +public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence - > + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// The id of the item the price will be associated with. + /// Configuration for cumulative_grouped_allocation pricing /// - public required string ItemID + public required ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } } /// - /// Configuration for minimum pricing + /// The id of the item the price will be associated with. /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig MinimumConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("item_id", value); } } /// @@ -17212,12 +81712,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig? ConversionRateConfig + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -17308,6 +81808,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 @@ -17347,9 +81860,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"); } @@ -17365,37 +81883,43 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceMinimum() + public ReplacePricePriceCumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public ReplacePricePriceMinimum( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum replacePricePriceMinimum +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceCumulativeGroupedAllocation( + ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation ) - : base(replacePricePriceMinimum) { } + : base(replacePricePriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public ReplacePricePriceMinimum(IReadOnlyDictionary rawData) + public ReplacePricePriceCumulativeGroupedAllocation( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimum(FrozenDictionary rawData) + ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17403,22 +81927,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceMinimumFromRaw - : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum.FromRawUnchecked(rawData); + ) => ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadenceConverter) -)] -public enum ReplacePricePriceMinimumCadence +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationCadenceConverter))] +public enum ReplacePricePriceCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -17428,10 +81950,10 @@ public enum ReplacePricePriceMinimumCadence Custom, } -sealed class ReplacePricePriceMinimumCadenceConverter - : JsonConverter +sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence Read( + public override ReplacePricePriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17439,49 +81961,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceMinimumCadence - .Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceMinimumCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceMinimumCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceMinimumCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceMinimumCadence - .OneTime, - "custom" => global::Orb - .Models - .Beta - .ExternalPlanID - .ReplacePricePriceMinimumCadence - .Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence)(-1), + "annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + "semi_annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly, + "quarterly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly, + "one_time" => ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime, + "custom" => ReplacePricePriceCumulativeGroupedAllocationCadence.Custom, + _ => (ReplacePricePriceCumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence value, + ReplacePricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -17489,18 +81981,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence.Annual => - "annual", - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence.Monthly => - "monthly", - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence.Quarterly => - "quarterly", - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence.OneTime => - "one_time", - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumCadence.Custom => - "custom", + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual => "annual", + ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly => "monthly", + ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", + ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime => "one_time", + ReplacePricePriceCumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -17511,109 +81997,128 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfigFromRaw + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class ReplacePricePriceMinimumMinimumConfig : JsonModel +public sealed record class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + : JsonModel { /// - /// The minimum amount to apply + /// The overall allocation across all groups /// - public required string MinimumAmount + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("cumulative_allocation", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// The allocation per individual group /// - public bool? Prorated + public required string GroupAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNotNullClass("group_allocation"); } - init + init { this._rawData.Set("group_allocation", value); } + } + + /// + /// The event property used to group usage before applying allocations + /// + public required string GroupingKey + { + get { - if (value == null) - { - return; - } + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } - this._rawData.Set("prorated", value); + /// + /// The amount to charge for each unit outside of the allocation + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; } - public ReplacePricePriceMinimumMinimumConfig() { } + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } - public ReplacePricePriceMinimumMinimumConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig replacePricePriceMinimumMinimumConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) - : base(replacePricePriceMinimumMinimumConfig) { } + : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceMinimumMinimumConfig(IReadOnlyDictionary rawData) + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimumMinimumConfig(FrozenDictionary rawData) + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public ReplacePricePriceMinimumMinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class ReplacePricePriceMinimumMinimumConfigFromRaw - : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumMinimumConfig.FromRawUnchecked( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( rawData ); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfigConverter) -)] -public record class ReplacePricePriceMinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] +public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -17630,7 +82135,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17639,7 +82144,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17648,7 +82153,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -17730,7 +82235,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -17766,16 +82271,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -17794,18 +82299,18 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -17813,13 +82318,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplacePricePriceMinimumConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig? Read( + public override ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17884,7 +82402,7 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig( + return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -17893,7 +82411,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig value, + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -17902,30 +82420,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 +82481,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 +82552,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" ); } @@ -18139,6 +82648,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 @@ -18196,6 +82718,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -18205,10 +82728,11 @@ public ReplacePricePricePercent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public ReplacePricePricePercent( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent replacePricePricePercent - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePricePercent(ReplacePricePricePercent replacePricePricePercent) : base(replacePricePricePercent) { } +#pragma warning restore CS8618 public ReplacePricePricePercent(IReadOnlyDictionary rawData) { @@ -18225,8 +82749,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 +82758,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 +82781,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 +82791,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 +82811,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 +82831,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 @@ -18373,10 +82858,13 @@ public override void Validate() public ReplacePricePricePercentPercentConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePricePercentPercentConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentPercentConfig replacePricePricePercentPercentConfig + ReplacePricePricePercentPercentConfig replacePricePricePercentPercentConfig ) : base(replacePricePricePercentPercentConfig) { } +#pragma warning restore CS8618 public ReplacePricePricePercentPercentConfig(IReadOnlyDictionary rawData) { @@ -18391,8 +82879,8 @@ public ReplacePricePricePercentPercentConfig(IReadOnlyDictionary - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentPercentConfig FromRawUnchecked( + /// + public static ReplacePricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -18408,20 +82896,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 +83063,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,12 +83092,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.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() { @@ -18622,13 +83103,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } 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 +83187,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 +83203,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 +83225,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 +83335,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" ); } @@ -18948,6 +83431,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 @@ -19010,6 +83506,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -19019,10 +83516,11 @@ public ReplacePricePriceEventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public ReplacePricePriceEventOutput( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput replacePricePriceEventOutput - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceEventOutput(ReplacePricePriceEventOutput replacePricePriceEventOutput) : base(replacePricePriceEventOutput) { } +#pragma warning restore CS8618 public ReplacePricePriceEventOutput(IReadOnlyDictionary rawData) { @@ -19039,8 +83537,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 +83546,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 +83569,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 +83579,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 +83599,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 +83619,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 @@ -19237,10 +83677,13 @@ public override void Validate() public ReplacePricePriceEventOutputEventOutputConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReplacePricePriceEventOutputEventOutputConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputEventOutputConfig replacePricePriceEventOutputEventOutputConfig + ReplacePricePriceEventOutputEventOutputConfig replacePricePriceEventOutputEventOutputConfig ) : base(replacePricePriceEventOutputEventOutputConfig) { } +#pragma warning restore CS8618 public ReplacePricePriceEventOutputEventOutputConfig( IReadOnlyDictionary rawData @@ -19257,8 +83700,8 @@ IReadOnlyDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputEventOutputConfig FromRawUnchecked( + /// + public static ReplacePricePriceEventOutputEventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -19274,20 +83717,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 +83884,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,12 +83913,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.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() { @@ -19488,13 +83924,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } 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 +84008,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputConversionRateConfig( - element - ); + return new ReplacePricePriceEventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputConversionRateConfig value, + ReplacePricePriceEventOutputConversionRateConfig value, JsonSerializerOptions options ) { diff --git a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParams.cs index be2e0796f..a4554496b 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,36 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParams.cs index 48f536f06..2167719b5 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +154,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/PlanVersion.cs b/src/Orb/Models/Beta/PlanVersion.cs index 2e2dc1603..d98d6bbfa 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) { @@ -549,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() { @@ -560,7 +563,23 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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/Beta/PlanVersionPhase.cs b/src/Orb/Models/Beta/PlanVersionPhase.cs index c31e3cce9..1952ebc5d 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); } } @@ -94,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) { @@ -126,7 +127,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 +147,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 +166,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/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..11cec3fea 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) { @@ -352,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 { @@ -893,9 +897,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 +1008,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 +1135,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 +1309,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 +1799,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) { @@ -2193,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() { @@ -2204,7 +2223,23 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + MonetaryUsageDiscountAdjustment _ => 0, + MonetaryAmountDiscountAdjustment _ => 1, + MonetaryPercentageDiscountAdjustment _ => 2, + MonetaryMinimumAdjustment _ => 3, + MonetaryMaximumAdjustment _ => 4, + _ => -1, + }; + } } sealed class LineItemAdjustmentConverter : JsonConverter @@ -2606,10 +2641,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() { @@ -2617,7 +2652,21 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + MatrixSubLineItem _ => 0, + TierSubLineItem _ => 1, + OtherSubLineItem _ => 2, + _ => -1, + }; + } } sealed class SubLineItemConverter : JsonConverter @@ -2835,8 +2884,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..31b616e82 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) { @@ -334,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() { @@ -345,7 +348,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + PercentageDiscount _ => 0, + AmountDiscount _ => 1, + _ => -1, + }; + } } sealed class CouponDiscountConverter : JsonConverter diff --git a/src/Orb/Models/Coupons/CouponArchiveParams.cs b/src/Orb/Models/Coupons/CouponArchiveParams.cs index c952ddf51..25442ff68 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Coupons/CouponCreateParams.cs b/src/Orb/Models/Coupons/CouponCreateParams.cs index 036e75ba0..783b815c0 100644 --- a/src/Orb/Models/Coupons/CouponCreateParams.cs +++ b/src/Orb/Models/Coupons/CouponCreateParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Coupons; /// /// This endpoint allows the creation of coupons, which can then be redeemed at subscription /// creation or plan change. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CouponCreateParams : ParamsBase +public record class CouponCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -23,14 +27,12 @@ public IReadOnlyDictionary RawBodyData get { return this._rawBodyData.Freeze(); } } - public required global::Orb.Models.Coupons.Discount Discount + public required Discount Discount { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullClass( - "discount" - ); + return this._rawBodyData.GetNotNullClass("discount"); } init { this._rawBodyData.Set("discount", value); } } @@ -78,11 +80,14 @@ public long? MaxRedemptions public CouponCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CouponCreateParams(CouponCreateParams couponCreateParams) : base(couponCreateParams) { this._rawBodyData = new(couponCreateParams._rawBodyData); } +#pragma warning restore CS8618 public CouponCreateParams( IReadOnlyDictionary rawHeaderData, @@ -123,6 +128,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + public virtual bool Equals(CouponCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/coupons") @@ -148,6 +181,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(DiscountConverter))] @@ -298,10 +336,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,10 +359,10 @@ public override void Validate() this.Switch((percentage) => percentage.Validate(), (amount) => amount.Validate()); } - public virtual bool Equals(global::Orb.Models.Coupons.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() { @@ -333,12 +370,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + Percentage _ => 0, + Amount _ => 1, + _ => -1, + }; + } } -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 +447,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); } @@ -455,8 +501,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) { @@ -532,8 +581,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/CouponFetchParams.cs b/src/Orb/Models/Coupons/CouponFetchParams.cs index bd33502d5..9df10a990 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Coupons/CouponListPage.cs b/src/Orb/Models/Coupons/CouponListPage.cs index 3febee959..ef0181222 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; @@ -62,5 +63,20 @@ 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) + { + 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/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/Coupons/CouponListParams.cs b/src/Orb/Models/Coupons/CouponListParams.cs index 08ed5b233..639e563bb 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,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(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 +166,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/SubscriptionListPage.cs b/src/Orb/Models/Coupons/Subscriptions/SubscriptionListPage.cs index 7220cf504..f3ef2dae1 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; @@ -64,5 +65,20 @@ 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) + { + 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/Coupons/Subscriptions/SubscriptionListParams.cs b/src/Orb/Models/Coupons/Subscriptions/SubscriptionListParams.cs index aa9f3573d..97241519d 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/CreditBlocks/CreditBlockDeleteParams.cs b/src/Orb/Models/CreditBlocks/CreditBlockDeleteParams.cs index 1969fb284..fe5ddf6aa 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/CreditBlocks/CreditBlockListInvoicesParams.cs b/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesParams.cs new file mode 100644 index 000000000..859715280 --- /dev/null +++ b/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesParams.cs @@ -0,0 +1,133 @@ +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( + 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 + ); + + 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/CreditBlocks/CreditBlockRetrieveParams.cs b/src/Orb/Models/CreditBlocks/CreditBlockRetrieveParams.cs index 2754063d0..14a44931f 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/CreditBlocks/CreditBlockRetrieveResponse.cs b/src/Orb/Models/CreditBlocks/CreditBlockRetrieveResponse.cs index 473a89a0a..5ea290e11 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) ); @@ -86,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 @@ -96,14 +116,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); } } @@ -120,14 +138,18 @@ public override void Validate() item.Validate(); } _ = this.MaximumInitialBalance; + _ = this.Metadata; _ = this.PerUnitCostBasis; this.Status.Validate(); } public CreditBlockRetrieveResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditBlockRetrieveResponse(CreditBlockRetrieveResponse creditBlockRetrieveResponse) : base(creditBlockRetrieveResponse) { } +#pragma warning restore CS8618 public CreditBlockRetrieveResponse(IReadOnlyDictionary rawData) { @@ -159,25 +181,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 +200,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,8 +239,11 @@ public override void Validate() public Filter() { } - public Filter(global::Orb.Models.CreditBlocks.Filter filter) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Filter(Filter filter) : base(filter) { } +#pragma warning restore CS8618 public Filter(IReadOnlyDictionary rawData) { @@ -242,27 +258,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 +285,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 +295,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 +327,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 +344,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 +367,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 +384,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/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 d77b47d4a..2054ce4d5 100644 --- a/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs +++ b/src/Orb/Models/CreditNotes/CreditNoteCreateParams.cs @@ -38,8 +38,12 @@ namespace Orb.Models.CreditNotes; /// Note: Both start_date and end_date are inclusive - the service period will /// cover both the start date and end date completely (from start of start_date to /// end of end_date). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CreditNoteCreateParams : ParamsBase +public record class CreditNoteCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -47,18 +51,16 @@ public IReadOnlyDictionary RawBodyData get { return this._rawBodyData.Freeze(); } } - public required IReadOnlyList LineItems + public required IReadOnlyList LineItems { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullStruct< - ImmutableArray - >("line_items"); + return this._rawBodyData.GetNotNullStruct>("line_items"); } init { - this._rawBodyData.Set>( + this._rawBodyData.Set>( "line_items", ImmutableArray.ToImmutableArray(value) ); @@ -68,14 +70,12 @@ public IReadOnlyDictionary RawBodyData /// /// An optional reason for the credit note. /// - public required ApiEnum Reason + public required ApiEnum Reason { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullClass< - ApiEnum - >("reason"); + return this._rawBodyData.GetNotNullClass>("reason"); } init { this._rawBodyData.Set("reason", value); } } @@ -129,11 +129,14 @@ public string? StartDate public CreditNoteCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditNoteCreateParams(CreditNoteCreateParams creditNoteCreateParams) : base(creditNoteCreateParams) { this._rawBodyData = new(creditNoteCreateParams._rawBodyData); } +#pragma warning restore CS8618 public CreditNoteCreateParams( IReadOnlyDictionary rawHeaderData, @@ -174,6 +177,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + public virtual bool Equals(CreditNoteCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/credit_notes") @@ -199,14 +230,14 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.CreditNotes.LineItem, - global::Orb.Models.CreditNotes.LineItemFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class LineItem : JsonModel { /// @@ -279,8 +310,11 @@ public override void Validate() public LineItem() { } - public LineItem(global::Orb.Models.CreditNotes.LineItem lineItem) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LineItem(LineItem lineItem) : base(lineItem) { } +#pragma warning restore CS8618 public LineItem(IReadOnlyDictionary rawData) { @@ -295,27 +329,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 +355,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 +365,24 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "duplicate" => global::Orb.Models.CreditNotes.Reason.Duplicate, - "fraudulent" => global::Orb.Models.CreditNotes.Reason.Fraudulent, - "order_change" => global::Orb.Models.CreditNotes.Reason.OrderChange, - "product_unsatisfactory" => global::Orb.Models.CreditNotes.Reason.ProductUnsatisfactory, - _ => (global::Orb.Models.CreditNotes.Reason)(-1), + "duplicate" => Reason.Duplicate, + "fraudulent" => Reason.Fraudulent, + "order_change" => Reason.OrderChange, + "product_unsatisfactory" => Reason.ProductUnsatisfactory, + _ => (Reason)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.CreditNotes.Reason value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Reason value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.CreditNotes.Reason.Duplicate => "duplicate", - global::Orb.Models.CreditNotes.Reason.Fraudulent => "fraudulent", - global::Orb.Models.CreditNotes.Reason.OrderChange => "order_change", - global::Orb.Models.CreditNotes.Reason.ProductUnsatisfactory => - "product_unsatisfactory", + Reason.Duplicate => "duplicate", + Reason.Fraudulent => "fraudulent", + Reason.OrderChange => "order_change", + Reason.ProductUnsatisfactory => "product_unsatisfactory", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/CreditNotes/CreditNoteFetchParams.cs b/src/Orb/Models/CreditNotes/CreditNoteFetchParams.cs index 3ff4c726a..5278e20d5 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/CreditNotes/CreditNoteListPage.cs b/src/Orb/Models/CreditNotes/CreditNoteListPage.cs index 8e0ebe1c3..7cd64396b 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; @@ -63,5 +64,20 @@ 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) + { + 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/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/CreditNotes/CreditNoteListParams.cs b/src/Orb/Models/CreditNotes/CreditNoteListParams.cs index adff6e836..38cd3cbd0 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,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(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 +177,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/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..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 @@ -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) { @@ -638,6 +641,7 @@ public enum CustomerTaxIDType OmVat, PeRuc, PhTin, + PlNip, RoTin, RsPib, RuInn, @@ -760,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, @@ -884,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/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/BalanceTransactionCreateParams.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs index ac1d4a588..54086604a 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + public virtual bool Equals(BalanceTransactionCreateParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -139,9 +176,14 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter(typeof(global::Orb.Models.Customers.BalanceTransactions.TypeConverter))] +[JsonConverter(typeof(TypeConverter))] public enum Type { Increment, diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponse.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponse.cs index 226a4f498..cc56b8690 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); } } @@ -157,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) { @@ -192,7 +193,7 @@ IReadOnlyDictionary rawData ) => BalanceTransactionCreateResponse.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Customers.BalanceTransactions.ActionConverter))] +[JsonConverter(typeof(ActionConverter))] public enum Action { AppliedToInvoice, @@ -207,10 +208,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 +218,36 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "applied_to_invoice" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .AppliedToInvoice, - "manual_adjustment" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .ManualAdjustment, - "prorated_refund" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .ProratedRefund, - "revert_prorated_refund" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .RevertProratedRefund, - "return_from_voiding" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .ReturnFromVoiding, - "credit_note_applied" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .CreditNoteApplied, - "credit_note_voided" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .CreditNoteVoided, - "overpayment_refund" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .OverpaymentRefund, - "external_payment" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .ExternalPayment, - "small_invoice_carryover" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .SmallInvoiceCarryover, - _ => (global::Orb.Models.Customers.BalanceTransactions.Action)(-1), + "applied_to_invoice" => Action.AppliedToInvoice, + "manual_adjustment" => Action.ManualAdjustment, + "prorated_refund" => Action.ProratedRefund, + "revert_prorated_refund" => Action.RevertProratedRefund, + "return_from_voiding" => Action.ReturnFromVoiding, + "credit_note_applied" => Action.CreditNoteApplied, + "credit_note_voided" => Action.CreditNoteVoided, + "overpayment_refund" => Action.OverpaymentRefund, + "external_payment" => Action.ExternalPayment, + "small_invoice_carryover" => Action.SmallInvoiceCarryover, + _ => (Action)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Customers.BalanceTransactions.Action value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Action value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Customers.BalanceTransactions.Action.AppliedToInvoice => - "applied_to_invoice", - global::Orb.Models.Customers.BalanceTransactions.Action.ManualAdjustment => - "manual_adjustment", - global::Orb.Models.Customers.BalanceTransactions.Action.ProratedRefund => - "prorated_refund", - global::Orb.Models.Customers.BalanceTransactions.Action.RevertProratedRefund => - "revert_prorated_refund", - global::Orb.Models.Customers.BalanceTransactions.Action.ReturnFromVoiding => - "return_from_voiding", - global::Orb.Models.Customers.BalanceTransactions.Action.CreditNoteApplied => - "credit_note_applied", - global::Orb.Models.Customers.BalanceTransactions.Action.CreditNoteVoided => - "credit_note_voided", - global::Orb.Models.Customers.BalanceTransactions.Action.OverpaymentRefund => - "overpayment_refund", - global::Orb.Models.Customers.BalanceTransactions.Action.ExternalPayment => - "external_payment", - global::Orb.Models.Customers.BalanceTransactions.Action.SmallInvoiceCarryover => - "small_invoice_carryover", + Action.AppliedToInvoice => "applied_to_invoice", + Action.ManualAdjustment => "manual_adjustment", + Action.ProratedRefund => "prorated_refund", + Action.RevertProratedRefund => "revert_prorated_refund", + Action.ReturnFromVoiding => "return_from_voiding", + Action.CreditNoteApplied => "credit_note_applied", + Action.CreditNoteVoided => "credit_note_voided", + Action.OverpaymentRefund => "overpayment_refund", + Action.ExternalPayment => "external_payment", + Action.SmallInvoiceCarryover => "small_invoice_carryover", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPage.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPage.cs index 01a438acc..fcb3a087a 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; @@ -65,5 +66,20 @@ 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) + { + 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/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/BalanceTransactionListParams.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListParams.cs index fdc3ffad9..d2aee2f49 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +203,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/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/CostListByExternalIDParams.cs b/src/Orb/Models/Customers/Costs/CostListByExternalIDParams.cs index e9fd5b5cd..dbbf4197c 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,39 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +270,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/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/CostListParams.cs b/src/Orb/Models/Customers/Costs/CostListParams.cs index e87ca9141..37fe8f2c5 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +260,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/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/CreditListByExternalIDPage.cs b/src/Orb/Models/Customers/Credits/CreditListByExternalIDPage.cs index cf2bb99fa..45b80d900 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; @@ -65,5 +66,20 @@ 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) + { + 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/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/CreditListByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs index 07cec886d..83931f69b 100644 --- a/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs @@ -16,8 +16,17 @@ 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. /// -public sealed record class CreditListByExternalIDParams : ParamsBase +public record class CreditListByExternalIDParams : ParamsBase { public string? ExternalCustomerID { get; init; } @@ -48,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. @@ -93,11 +142,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 +184,39 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +239,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/CreditListByExternalIDResponse.cs b/src/Orb/Models/Customers/Credits/CreditListByExternalIDResponse.cs index db3834dec..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,16 +142,20 @@ public override void Validate() item.Validate(); } _ = this.MaximumInitialBalance; + _ = this.Metadata; _ = this.PerUnitCostBasis; this.Status.Validate(); } public CreditListByExternalIDResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditListByExternalIDResponse( CreditListByExternalIDResponse creditListByExternalIDResponse ) : base(creditListByExternalIDResponse) { } +#pragma warning restore CS8618 public CreditListByExternalIDResponse(IReadOnlyDictionary rawData) { @@ -231,10 +257,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/CreditListPage.cs b/src/Orb/Models/Customers/Credits/CreditListPage.cs index 0e3c9b0d5..9380ce597 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; @@ -63,5 +64,20 @@ 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) + { + 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/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/CreditListParams.cs b/src/Orb/Models/Customers/Credits/CreditListParams.cs index 343f39fd5..ad81403b2 100644 --- a/src/Orb/Models/Customers/Credits/CreditListParams.cs +++ b/src/Orb/Models/Customers/Credits/CreditListParams.cs @@ -16,8 +16,17 @@ 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. /// -public sealed record class CreditListParams : ParamsBase +public record class CreditListParams : ParamsBase { public string? CustomerID { get; init; } @@ -48,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. @@ -93,11 +142,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 +184,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +231,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/Credits/CreditListResponse.cs b/src/Orb/Models/Customers/Credits/CreditListResponse.cs index 240ac4334..533e93329 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) ); @@ -81,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 @@ -91,14 +111,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); } } @@ -115,14 +133,18 @@ public override void Validate() item.Validate(); } _ = this.MaximumInitialBalance; + _ = this.Metadata; _ = this.PerUnitCostBasis; this.Status.Validate(); } public CreditListResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditListResponse(CreditListResponse creditListResponse) : base(creditListResponse) { } +#pragma warning restore CS8618 public CreditListResponse(IReadOnlyDictionary rawData) { @@ -156,25 +178,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 +197,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,8 +236,11 @@ public override void Validate() public Filter() { } - public Filter(global::Orb.Models.Customers.Credits.Filter filter) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Filter(Filter filter) : base(filter) { } +#pragma warning restore CS8618 public Filter(IReadOnlyDictionary rawData) { @@ -239,35 +255,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 +288,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 +312,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 +329,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 +352,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 +369,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/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 98de12804..057c79810 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs @@ -49,7 +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. +/// 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 @@ -94,8 +99,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 +128,8 @@ public required LedgerCreateEntryByExternalIDParamsBody Body public LedgerCreateEntryByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParams( LedgerCreateEntryByExternalIDParams ledgerCreateEntryByExternalIDParams ) @@ -128,6 +139,7 @@ LedgerCreateEntryByExternalIDParams ledgerCreateEntryByExternalIDParams this._rawBodyData = new(ledgerCreateEntryByExternalIDParams._rawBodyData); } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -168,6 +180,41 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +246,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(LedgerCreateEntryByExternalIDParamsBodyConverter))] @@ -617,10 +669,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() { @@ -628,7 +680,23 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + LedgerCreateEntryByExternalIDParamsBodyIncrement _ => 0, + LedgerCreateEntryByExternalIDParamsBodyDecrement _ => 1, + LedgerCreateEntryByExternalIDParamsBodyExpirationChange _ => 2, + LedgerCreateEntryByExternalIDParamsBodyVoid _ => 3, + LedgerCreateEntryByExternalIDParamsBodyAmendment _ => 4, + _ => -1, + }; + } } sealed class LedgerCreateEntryByExternalIDParamsBodyConverter @@ -973,10 +1041,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 @@ -1096,10 +1167,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 @@ -1306,6 +1380,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. /// @@ -1324,8 +1419,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 { @@ -1366,6 +1461,7 @@ public override void Validate() this.CustomDueDate?.Validate(); this.InvoiceDate?.Validate(); _ = this.ItemID; + _ = this.MarkAsPaid; _ = this.Memo; _ = this.NetTerms; _ = this.RequireSuccessfulPayment; @@ -1373,10 +1469,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 @@ -1618,10 +1717,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() { @@ -1629,7 +1728,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettingsCustomDueDateConverter @@ -1657,7 +1769,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) { @@ -1876,10 +1991,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() { @@ -1887,7 +2002,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettingsInvoiceDateConverter @@ -1915,7 +2043,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) { @@ -2035,10 +2166,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 @@ -2232,10 +2366,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 @@ -2411,10 +2548,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 @@ -2610,10 +2750,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/LedgerCreateEntryByExternalIDResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponse.cs index e4ad57565..c6f3c7b1b 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() { @@ -638,7 +638,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 47c8a79f9..2640a762b 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs @@ -49,7 +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. +/// 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 @@ -94,8 +99,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 +126,8 @@ public required Body Body public LedgerCreateEntryParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryParams(LedgerCreateEntryParams ledgerCreateEntryParams) : base(ledgerCreateEntryParams) { @@ -124,6 +135,7 @@ public LedgerCreateEntryParams(LedgerCreateEntryParams ledgerCreateEntryParams) this._rawBodyData = new(ledgerCreateEntryParams._rawBodyData); } +#pragma warning restore CS8618 public LedgerCreateEntryParams( IReadOnlyDictionary rawHeaderData, @@ -164,6 +176,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +234,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(BodyConverter))] @@ -567,10 +614,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() { @@ -578,7 +625,23 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + Increment _ => 0, + Decrement _ => 1, + ExpirationChange _ => 2, + Void _ => 3, + Amendment _ => 4, + _ => -1, + }; + } } sealed class BodyConverter : JsonConverter @@ -800,18 +863,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) ); @@ -894,8 +955,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) { @@ -936,25 +1000,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 +1019,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,8 +1058,11 @@ public override void Validate() public Filter() { } - public Filter(global::Orb.Models.Customers.Credits.Ledger.Filter filter) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Filter(Filter filter) : base(filter) { } +#pragma warning restore CS8618 public Filter(IReadOnlyDictionary rawData) { @@ -1019,35 +1077,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 +1110,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 +1134,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 +1151,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)) ), @@ -1192,6 +1239,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. /// @@ -1210,8 +1278,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 { @@ -1252,6 +1320,7 @@ public override void Validate() this.CustomDueDate?.Validate(); this.InvoiceDate?.Validate(); _ = this.ItemID; + _ = this.MarkAsPaid; _ = this.Memo; _ = this.NetTerms; _ = this.RequireSuccessfulPayment; @@ -1259,8 +1328,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) { @@ -1475,10 +1547,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() { @@ -1486,7 +1558,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class CustomDueDateConverter : JsonConverter @@ -1513,7 +1598,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) { @@ -1709,10 +1797,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() { @@ -1720,7 +1808,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class InvoiceDateConverter : JsonConverter @@ -1747,7 +1848,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) { @@ -1862,8 +1966,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) { @@ -2046,8 +2153,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) { @@ -2210,8 +2320,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) { @@ -2395,8 +2508,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/LedgerCreateEntryResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryResponse.cs index b579876c4..04ab956e5 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() { @@ -616,7 +616,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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/LedgerListByExternalIDPage.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPage.cs index f4ed0b2ba..056857986 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; @@ -65,5 +66,20 @@ 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) + { + 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/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/LedgerListByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs index e2c4466b5..22cf1e569 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs @@ -31,11 +31,8 @@ namespace Orb.Models.Customers.Credits.Ledger; /// /// As usage for a customer is reported into Orb, credits may be deducted according /// to the customer's plan configuration. An automated deduction of this type will -/// result in a ledger entry, also with a starting and ending balance. In order to -/// provide better tracing capabilities for automatic deductions, Orb always associates -/// each automatic deduction with the `event_id` at the time of ingestion, used to -/// pinpoint _why_ credit deduction took place and to ensure that credits are never -/// deducted without an associated usage event. +/// result in a ledger entry, also with a starting and ending balance. Each day's +/// usage for a particular price, invoice, and block will be grouped into a single entry. /// /// By default, Orb uses an algorithm that automatically deducts from the *soonest /// expiring credit block* first in order to ensure that all credits are utilized @@ -77,8 +74,12 @@ namespace Orb.Models.Customers.Credits.Ledger; /// ## Amendment When credits are added to a customer's balance as a result /// of a correction, this entry will be added to the ledger to indicate the adjustment /// of credits. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class LedgerListByExternalIDParams : ParamsBase +public record class LedgerListByExternalIDParams : ParamsBase { public string? ExternalCustomerID { get; init; } @@ -206,11 +207,14 @@ public string? MinimumAmount public LedgerListByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerListByExternalIDParams(LedgerListByExternalIDParams ledgerListByExternalIDParams) : base(ledgerListByExternalIDParams) { this.ExternalCustomerID = ledgerListByExternalIDParams.ExternalCustomerID; } +#pragma warning restore CS8618 public LedgerListByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -245,6 +249,39 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +304,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/LedgerListByExternalIDResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponse.cs index 08954b4cd..061943cf3 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() { @@ -626,7 +626,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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/LedgerListPage.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListPage.cs index 2fd61302a..7aa4cae8a 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; @@ -63,5 +64,20 @@ 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) + { + 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/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/LedgerListParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs index 6e6519a41..cdf4522e1 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs @@ -31,11 +31,8 @@ namespace Orb.Models.Customers.Credits.Ledger; /// /// As usage for a customer is reported into Orb, credits may be deducted according /// to the customer's plan configuration. An automated deduction of this type will -/// result in a ledger entry, also with a starting and ending balance. In order to -/// provide better tracing capabilities for automatic deductions, Orb always associates -/// each automatic deduction with the `event_id` at the time of ingestion, used to -/// pinpoint _why_ credit deduction took place and to ensure that credits are never -/// deducted without an associated usage event. +/// result in a ledger entry, also with a starting and ending balance. Each day's +/// usage for a particular price, invoice, and block will be grouped into a single entry. /// /// By default, Orb uses an algorithm that automatically deducts from the *soonest /// expiring credit block* first in order to ensure that all credits are utilized @@ -77,8 +74,12 @@ namespace Orb.Models.Customers.Credits.Ledger; /// ## Amendment When credits are added to a customer's balance as a result /// of a correction, this entry will be added to the ledger to indicate the adjustment /// of credits. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class LedgerListParams : ParamsBase +public record class LedgerListParams : ParamsBase { public string? CustomerID { get; init; } @@ -204,11 +205,14 @@ public string? MinimumAmount public LedgerListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerListParams(LedgerListParams ledgerListParams) : base(ledgerListParams) { this.CustomerID = ledgerListParams.CustomerID; } +#pragma warning restore CS8618 public LedgerListParams( IReadOnlyDictionary rawHeaderData, @@ -243,6 +247,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +294,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/Ledger/LedgerListResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListResponse.cs index 840a5e070..fea2d00dc 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() { @@ -610,7 +610,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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/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 c260d51ff..de37211f0 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,41 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +265,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -313,10 +360,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 3d1ff3c2d..d2135c7fc 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +253,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -301,8 +343,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/TopUpDeleteByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParams.cs index 67c920def..48d4443c9 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,38 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +124,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..efe5864e5 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,36 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/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/TopUpListByExternalIDPage.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPage.cs index 78aa63b2c..7abeb4ac9 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; @@ -63,5 +64,20 @@ 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) + { + 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/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/TopUpListByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDParams.cs index 4ea1cbcfc..3ff271a3e 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,39 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/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/TopUpListPage.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListPage.cs index e35ea6aed..3fa1dfdcb 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; @@ -63,5 +64,20 @@ 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) + { + 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/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/TopUpListParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListParams.cs index affa167c2..3b9d3d428 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/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..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 { @@ -487,8 +488,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 +565,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 +700,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 +770,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 +895,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 +996,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 +1112,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 f548db5bd..ec8add79a 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 @@ -364,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 { @@ -417,11 +422,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 +470,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +523,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -499,14 +540,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 +556,7 @@ public sealed record class PaymentConfiguration : JsonModel return; } - this._rawData.Set?>( + this._rawData.Set?>( "payment_providers", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -533,8 +574,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) { @@ -566,9 +610,7 @@ IReadOnlyDictionary rawData ) => PaymentConfiguration.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class PaymentProvider : JsonModel { /// @@ -623,8 +665,11 @@ public override void Validate() public PaymentProvider() { } - public PaymentProvider(global::Orb.Models.Customers.PaymentProvider paymentProvider) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PaymentProvider(PaymentProvider paymentProvider) : base(paymentProvider) { } +#pragma warning restore CS8618 public PaymentProvider(IReadOnlyDictionary rawData) { @@ -640,9 +685,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 +698,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); } /// @@ -1127,10 +1169,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() { @@ -1138,7 +1180,24 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 @@ -1355,8 +1414,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) { @@ -1447,8 +1509,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) { @@ -1539,8 +1604,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/CustomerDeleteParams.cs b/src/Orb/Models/Customers/CustomerDeleteParams.cs index 9ea9ff627..3816edc4f 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/CustomerFetchByExternalIDParams.cs b/src/Orb/Models/Customers/CustomerFetchByExternalIDParams.cs index 567a20645..4fa121192 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,39 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/CustomerFetchParams.cs b/src/Orb/Models/Customers/CustomerFetchParams.cs index df3020ce6..215007d28 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/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/CustomerListPage.cs b/src/Orb/Models/Customers/CustomerListPage.cs index 994b7ca0a..ff7eb3360 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; @@ -62,5 +63,20 @@ 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) + { + 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/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/CustomerListParams.cs b/src/Orb/Models/Customers/CustomerListParams.cs index aa88c2b67..53d89372c 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,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(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 +179,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..fcc3b81a5 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,41 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +128,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..e4dc974be 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Customers/CustomerUpdateByExternalIDParams.cs b/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs index cdaab38bd..b1c1cb443 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 @@ -103,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 { @@ -365,31 +370,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 { @@ -403,6 +409,8 @@ public CustomerTaxID? TaxID public CustomerUpdateByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateByExternalIDParams( CustomerUpdateByExternalIDParams customerUpdateByExternalIDParams ) @@ -412,6 +420,7 @@ CustomerUpdateByExternalIDParams customerUpdateByExternalIDParams this._rawBodyData = new(customerUpdateByExternalIDParams._rawBodyData); } +#pragma warning restore CS8618 public CustomerUpdateByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -452,6 +461,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +519,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -531,10 +575,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 @@ -640,10 +687,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 @@ -1206,10 +1256,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() { @@ -1217,7 +1267,24 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewAvalaraTaxConfiguration _ => 0, + NewTaxJarConfiguration _ => 1, + NewSphereConfiguration _ => 2, + CustomerUpdateByExternalIDParamsTaxConfigurationNumeral _ => 3, + CustomerUpdateByExternalIDParamsTaxConfigurationAnrok _ => 4, + CustomerUpdateByExternalIDParamsTaxConfigurationStripe _ => 5, + _ => -1, + }; + } } sealed class CustomerUpdateByExternalIDParamsTaxConfigurationConverter @@ -1452,10 +1519,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 @@ -1559,10 +1629,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 @@ -1666,10 +1739,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 084533d42..03072a599 100644 --- a/src/Orb/Models/Customers/CustomerUpdateParams.cs +++ b/src/Orb/Models/Customers/CustomerUpdateParams.cs @@ -15,10 +15,15 @@ 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 +/// cause existing derived classes to break. /// -public sealed record class CustomerUpdateParams : ParamsBase +public record class CustomerUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -104,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 { @@ -366,31 +372,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 { @@ -404,6 +411,8 @@ public CustomerTaxID? TaxID public CustomerUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateParams(CustomerUpdateParams customerUpdateParams) : base(customerUpdateParams) { @@ -411,6 +420,7 @@ public CustomerUpdateParams(CustomerUpdateParams customerUpdateParams) this._rawBodyData = new(customerUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public CustomerUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -451,6 +461,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +519,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -530,10 +575,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 @@ -633,10 +681,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 @@ -1193,10 +1244,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() { @@ -1204,7 +1255,24 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewAvalaraTaxConfiguration _ => 0, + NewTaxJarConfiguration _ => 1, + NewSphereConfiguration _ => 2, + CustomerUpdateParamsTaxConfigurationNumeral _ => 3, + CustomerUpdateParamsTaxConfigurationAnrok _ => 4, + CustomerUpdateParamsTaxConfigurationStripe _ => 5, + _ => -1, + }; + } } sealed class CustomerUpdateParamsTaxConfigurationConverter @@ -1439,10 +1507,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 @@ -1544,10 +1615,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 @@ -1649,10 +1723,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/DimensionalPriceGroupCreateParams.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParams.cs index 727a7b7a3..f0e2ead9a 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,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +211,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/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/DimensionalPriceGroups/DimensionalPriceGroupListPage.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListPage.cs index cf31718c3..cbb065993 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; @@ -65,5 +66,20 @@ 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) + { + 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/DimensionalPriceGroups/DimensionalPriceGroupListParams.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListParams.cs index b0850dda4..d6cd20146 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,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(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 +137,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..92c1bd5fc 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,39 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/DimensionalPriceGroups/DimensionalPriceGroupUpdateParams.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParams.cs index 14f6f05e1..4302241cd 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,41 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParams.cs b/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParams.cs index abd46f11f..74e26db29 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,39 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +121,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..5779efc6f 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,41 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +190,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..f9f8aecd1 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/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/BackfillCreateParams.cs b/src/Orb/Models/Events/Backfills/BackfillCreateParams.cs index 599437f17..3c3243723 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,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +270,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/Backfills/BackfillCreateResponse.cs b/src/Orb/Models/Events/Backfills/BackfillCreateResponse.cs index 8e39a8db8..36ffce44f 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); } } @@ -172,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) { @@ -208,7 +209,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 +218,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 +228,24 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "pending" => global::Orb.Models.Events.Backfills.Status.Pending, - "reflected" => global::Orb.Models.Events.Backfills.Status.Reflected, - "pending_revert" => global::Orb.Models.Events.Backfills.Status.PendingRevert, - "reverted" => global::Orb.Models.Events.Backfills.Status.Reverted, - _ => (global::Orb.Models.Events.Backfills.Status)(-1), + "pending" => Status.Pending, + "reflected" => Status.Reflected, + "pending_revert" => Status.PendingRevert, + "reverted" => Status.Reverted, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Events.Backfills.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Events.Backfills.Status.Pending => "pending", - global::Orb.Models.Events.Backfills.Status.Reflected => "reflected", - global::Orb.Models.Events.Backfills.Status.PendingRevert => "pending_revert", - global::Orb.Models.Events.Backfills.Status.Reverted => "reverted", + Status.Pending => "pending", + Status.Reflected => "reflected", + Status.PendingRevert => "pending_revert", + Status.Reverted => "reverted", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Events/Backfills/BackfillFetchParams.cs b/src/Orb/Models/Events/Backfills/BackfillFetchParams.cs index da16f794e..f944f40e1 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/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/BackfillListPage.cs b/src/Orb/Models/Events/Backfills/BackfillListPage.cs index 484a2f953..a5ef4e97c 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; @@ -63,5 +64,20 @@ 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) + { + 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/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/BackfillListParams.cs b/src/Orb/Models/Events/Backfills/BackfillListParams.cs index bde773bd4..d65c1430f 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,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(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 +140,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/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/BackfillRevertParams.cs b/src/Orb/Models/Events/Backfills/BackfillRevertParams.cs index 5aaaacb07..c4f1ef481 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/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/EventDeprecateParams.cs b/src/Orb/Models/Events/EventDeprecateParams.cs index 59cac2ffa..b5ff6d266 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/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 dc9ebda8b..4f9f6c1b6 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,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +342,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] @@ -416,8 +456,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/EventSearchParams.cs b/src/Orb/Models/Events/EventSearchParams.cs index 9dc0f9842..d129f2580 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,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +191,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/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/EventUpdateParams.cs b/src/Orb/Models/Events/EventUpdateParams.cs index 05eb52a75..9e9b0e775 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +248,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/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 617b5f4dc..cea58a513 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)); } } @@ -41,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) { @@ -64,7 +62,7 @@ public static EventVolumes FromRawUnchecked(IReadOnlyDictionary data) + public EventVolumes(IReadOnlyList data) : this() { this.Data = data; @@ -82,12 +80,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,8 +126,11 @@ public override void Validate() public Data() { } - public Data(global::Orb.Models.Events.Volume.Data data) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Data(Data data) : base(data) { } +#pragma warning restore CS8618 public Data(IReadOnlyDictionary rawData) { @@ -149,19 +145,16 @@ public Data(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Events.Volume.Data FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Data FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class DataFromRaw : IFromRawJson +class DataFromRaw : IFromRawJson { /// - public global::Orb.Models.Events.Volume.Data FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Events.Volume.Data.FromRawUnchecked(rawData); + public Data FromRawUnchecked(IReadOnlyDictionary rawData) => + Data.FromRawUnchecked(rawData); } diff --git a/src/Orb/Models/Events/Volume/VolumeListParams.cs b/src/Orb/Models/Events/Volume/VolumeListParams.cs index eec55f973..6ef1b06aa 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,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(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 +184,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/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..2f620c274 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 { @@ -747,9 +748,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 +859,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 +989,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 +1172,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 +1676,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) { @@ -2081,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() { @@ -2092,7 +2108,23 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + MonetaryUsageDiscountAdjustment _ => 0, + MonetaryAmountDiscountAdjustment _ => 1, + MonetaryPercentageDiscountAdjustment _ => 2, + MonetaryMinimumAdjustment _ => 3, + MonetaryMaximumAdjustment _ => 4, + _ => -1, + }; + } } sealed class InvoiceLineItemAdjustmentConverter : JsonConverter @@ -2502,10 +2534,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() { @@ -2513,7 +2545,21 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + MatrixSubLineItem _ => 0, + TierSubLineItem _ => 1, + OtherSubLineItem _ => 2, + _ => -1, + }; + } } sealed class InvoiceLineItemSubLineItemConverter : JsonConverter @@ -2731,8 +2777,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/InvoiceLevelDiscount.cs b/src/Orb/Models/InvoiceLevelDiscount.cs index 33a9f2f42..6f07cd8f8 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() { @@ -249,7 +249,21 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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/InvoiceLineItemCreateParams.cs b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateParams.cs index 2604e2c94..6629ae01b 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,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +236,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs index 8e2e54507..8364ff91d 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) ); @@ -313,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) { @@ -348,7 +347,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 +677,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,10 +714,10 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.InvoiceLineItems.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() { @@ -734,12 +725,28 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + MonetaryUsageDiscountAdjustment _ => 0, + MonetaryAmountDiscountAdjustment _ => 1, + MonetaryPercentageDiscountAdjustment _ => 2, + MonetaryMinimumAdjustment _ => 3, + MonetaryMaximumAdjustment _ => 4, + _ => -1, + }; + } } -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 +878,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 +893,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 +1114,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,10 +1143,10 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.InvoiceLineItems.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() { @@ -1153,12 +1154,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + MatrixSubLineItem _ => 0, + TierSubLineItem _ => 1, + OtherSubLineItem _ => 2, + _ => -1, + }; + } } -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 +1260,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/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 c572f34f6..5e89a0a47 100644 --- a/src/Orb/Models/Invoices/InvoiceCreateParams.cs +++ b/src/Orb/Models/Invoices/InvoiceCreateParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Invoices; /// /// This endpoint is used to create a one-off invoice for a customer. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceCreateParams : ParamsBase +public record class InvoiceCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -51,24 +55,37 @@ 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) ); } } + /// + /// 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. @@ -204,11 +221,14 @@ public bool? WillAutoIssue public InvoiceCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceCreateParams(InvoiceCreateParams invoiceCreateParams) : base(invoiceCreateParams) { this._rawBodyData = new(invoiceCreateParams._rawBodyData); } +#pragma warning restore CS8618 public InvoiceCreateParams( IReadOnlyDictionary rawHeaderData, @@ -249,6 +269,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + public virtual bool Equals(InvoiceCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/invoices") @@ -274,14 +322,14 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Invoices.LineItem, - global::Orb.Models.Invoices.LineItemFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class LineItem : JsonModel { /// @@ -307,14 +355,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,8 +431,11 @@ public override void Validate() public LineItem() { } - public LineItem(global::Orb.Models.Invoices.LineItem lineItem) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LineItem(LineItem lineItem) : base(lineItem) { } +#pragma warning restore CS8618 public LineItem(IReadOnlyDictionary rawData) { @@ -401,32 +450,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 +480,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 +495,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)) ), @@ -634,10 +680,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() { @@ -645,7 +691,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class DueDateConverter : JsonConverter @@ -672,7 +731,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/InvoiceDeleteLineItemParams.cs b/src/Orb/Models/Invoices/InvoiceDeleteLineItemParams.cs index 526c14b14..93d7b5c8c 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,36 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Invoices/InvoiceFetchParams.cs b/src/Orb/Models/Invoices/InvoiceFetchParams.cs index 563df22da..f89529bf0 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Invoices/InvoiceFetchUpcomingParams.cs b/src/Orb/Models/Invoices/InvoiceFetchUpcomingParams.cs index 193ec1bf6..2507fb9fe 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,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(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 +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/Invoices/InvoiceFetchUpcomingResponse.cs b/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs index 01a532f8c..d96318111 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) + ); } } @@ -214,31 +211,32 @@ public required CustomerMinified Customer /// 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 { @@ -355,14 +353,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 +504,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) ); @@ -747,9 +743,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) @@ -783,12 +782,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,8 +857,11 @@ public override void Validate() public AutoCollection() { } - public AutoCollection(global::Orb.Models.Invoices.AutoCollection autoCollection) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public AutoCollection(AutoCollection autoCollection) : base(autoCollection) { } +#pragma warning restore CS8618 public AutoCollection(IReadOnlyDictionary rawData) { @@ -879,29 +876,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,8 +984,11 @@ public override void Validate() public CreditNote() { } - public CreditNote(global::Orb.Models.Invoices.CreditNote creditNote) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CreditNote(CreditNote creditNote) : base(creditNote) { } +#pragma warning restore CS8618 public CreditNote(IReadOnlyDictionary rawData) { @@ -1011,28 +1003,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 +1035,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,10 +1160,11 @@ public override void Validate() public CustomerBalanceTransaction() { } - public CustomerBalanceTransaction( - global::Orb.Models.Invoices.CustomerBalanceTransaction customerBalanceTransaction - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CustomerBalanceTransaction(CustomerBalanceTransaction customerBalanceTransaction) : base(customerBalanceTransaction) { } +#pragma warning restore CS8618 public CustomerBalanceTransaction(IReadOnlyDictionary rawData) { @@ -1194,8 +1179,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 +1188,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 +1211,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 +1221,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 +1260,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Invoices.TypeConverter))] +[JsonConverter(typeof(TypeConverter))] public enum Type { Increment, @@ -1325,7 +1304,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Invoices.InvoiceSourceConverter))] +[JsonConverter(typeof(InvoiceSourceConverter))] public enum InvoiceSource { Subscription, @@ -1333,9 +1312,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 +1322,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 +1339,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 +1391,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 +1552,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) ); @@ -1678,10 +1653,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) { @@ -1714,7 +1692,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 +2022,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,10 +2059,10 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Invoices.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() { @@ -2100,12 +2070,28 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + MonetaryUsageDiscountAdjustment _ => 0, + MonetaryAmountDiscountAdjustment _ => 1, + MonetaryPercentageDiscountAdjustment _ => 2, + MonetaryMinimumAdjustment _ => 3, + MonetaryMaximumAdjustment _ => 4, + _ => -1, + }; + } } -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 +2223,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 +2238,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 +2459,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,10 +2488,10 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Invoices.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() { @@ -2519,12 +2499,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + MatrixSubLineItem _ => 0, + TierSubLineItem _ => 1, + OtherSubLineItem _ => 2, + _ => -1, + }; + } } -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 +2605,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 +2620,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 +2665,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,8 +2731,11 @@ public override void Validate() public PaymentAttempt() { } - public PaymentAttempt(global::Orb.Models.Invoices.PaymentAttempt paymentAttempt) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PaymentAttempt(PaymentAttempt paymentAttempt) : base(paymentAttempt) { } +#pragma warning restore CS8618 public PaymentAttempt(IReadOnlyDictionary rawData) { @@ -2758,35 +2750,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 +2783,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 +2798,7 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Invoices.PaymentProvider.Stripe => "stripe", + PaymentProvider.Stripe => "stripe", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Invoices/InvoiceIssueParams.cs b/src/Orb/Models/Invoices/InvoiceIssueParams.cs index 4a7427ed2..b66e56938 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +165,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/InvoiceIssueSummaryParams.cs b/src/Orb/Models/Invoices/InvoiceIssueSummaryParams.cs new file mode 100644 index 000000000..987603c8d --- /dev/null +++ b/src/Orb/Models/Invoices/InvoiceIssueSummaryParams.cs @@ -0,0 +1,176 @@ +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( + 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 + ); + + 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/Invoices/InvoiceListPage.cs b/src/Orb/Models/Invoices/InvoiceListPage.cs index d663b4499..afd25c4d2 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; @@ -62,5 +63,20 @@ 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) + { + 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/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/InvoiceListParams.cs b/src/Orb/Models/Invoices/InvoiceListParams.cs index 3abf3b01e..24141e728 100644 --- a/src/Orb/Models/Invoices/InvoiceListParams.cs +++ b/src/Orb/Models/Invoices/InvoiceListParams.cs @@ -24,8 +24,12 @@ namespace Orb.Models.Invoices; /// When fetching any `draft` invoices, this returns the last-computed invoice /// values for each draft invoice, which may not always be up-to-date since Orb regularly /// refreshes invoices asynchronously. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. ///
-public sealed record class InvoiceListParams : ParamsBase +public record class InvoiceListParams : ParamsBase { public string? Amount { @@ -222,20 +226,21 @@ public long? Limit } } - public IReadOnlyList>? Status + public IReadOnlyList>? Status { get { this._rawQueryData.Freeze(); - return this._rawQueryData.GetNullableStruct< - ImmutableArray> - >("status"); + return this._rawQueryData.GetNullableStruct>>( + "status" + ); } init { - this._rawQueryData.Set - >?>("status", value == null ? null : ImmutableArray.ToImmutableArray(value)); + this._rawQueryData.Set>?>( + "status", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); } } @@ -251,8 +256,11 @@ public string? SubscriptionID public InvoiceListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceListParams(InvoiceListParams invoiceListParams) : base(invoiceListParams) { } +#pragma warning restore CS8618 public InvoiceListParams( IReadOnlyDictionary rawHeaderData, @@ -287,6 +295,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/invoices") @@ -303,6 +337,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(DateTypeConverter))] @@ -345,7 +384,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 +394,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 +404,26 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "draft" => global::Orb.Models.Invoices.Status.Draft, - "issued" => global::Orb.Models.Invoices.Status.Issued, - "paid" => global::Orb.Models.Invoices.Status.Paid, - "synced" => global::Orb.Models.Invoices.Status.Synced, - "void" => global::Orb.Models.Invoices.Status.Void, - _ => (global::Orb.Models.Invoices.Status)(-1), + "draft" => Status.Draft, + "issued" => Status.Issued, + "paid" => Status.Paid, + "synced" => Status.Synced, + "void" => Status.Void, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Invoices.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Invoices.Status.Draft => "draft", - global::Orb.Models.Invoices.Status.Issued => "issued", - global::Orb.Models.Invoices.Status.Paid => "paid", - global::Orb.Models.Invoices.Status.Synced => "synced", - global::Orb.Models.Invoices.Status.Void => "void", + Status.Draft => "draft", + Status.Issued => "issued", + Status.Paid => "paid", + Status.Synced => "synced", + Status.Void => "void", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Invoices/InvoiceListSummaryPage.cs b/src/Orb/Models/Invoices/InvoiceListSummaryPage.cs index 1ee08853d..b20455466 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; @@ -63,5 +64,20 @@ 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) + { + 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/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/InvoiceListSummaryParams.cs b/src/Orb/Models/Invoices/InvoiceListSummaryParams.cs index 72179935a..76d564580 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; @@ -27,8 +26,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 { @@ -239,24 +242,6 @@ public ApiEnum? Status init { this._rawQueryData.Set("status", value); } } - public IReadOnlyList>? StatusValue - { - get - { - this._rawQueryData.Freeze(); - return this._rawQueryData.GetNullableStruct< - ImmutableArray> - >("status"); - } - init - { - this._rawQueryData.Set>?>( - "status", - value == null ? null : ImmutableArray.ToImmutableArray(value) - ); - } - } - public string? SubscriptionID { get @@ -269,8 +254,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 +293,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceListSummaryParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/invoices/summary") @@ -321,6 +335,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(InvoiceListSummaryParamsDateTypeConverter))] @@ -420,56 +439,3 @@ JsonSerializerOptions options ); } } - -[JsonConverter(typeof(StatusModelConverter))] -public enum StatusModel -{ - Draft, - Issued, - Paid, - Synced, - Void, -} - -sealed class StatusModelConverter : JsonConverter -{ - public override StatusModel Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "draft" => StatusModel.Draft, - "issued" => StatusModel.Issued, - "paid" => StatusModel.Paid, - "synced" => StatusModel.Synced, - "void" => StatusModel.Void, - _ => (StatusModel)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - StatusModel value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - StatusModel.Draft => "draft", - StatusModel.Issued => "issued", - StatusModel.Paid => "paid", - StatusModel.Synced => "synced", - StatusModel.Void => "void", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} diff --git a/src/Orb/Models/Invoices/InvoiceListSummaryResponse.cs b/src/Orb/Models/Invoices/InvoiceListSummaryResponse.cs index d5c4dfe40..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 { @@ -628,8 +629,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 +745,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 +885,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 +1075,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 +1419,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/Invoices/InvoiceMarkPaidParams.cs b/src/Orb/Models/Invoices/InvoiceMarkPaidParams.cs index 0dd75ea13..5ee1ca72d 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +176,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..43e81ef1b 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Invoices/InvoiceUpdateParams.cs b/src/Orb/Models/Invoices/InvoiceUpdateParams.cs index f5727977b..5b4359f85 100644 --- a/src/Orb/Models/Invoices/InvoiceUpdateParams.cs +++ b/src/Orb/Models/Invoices/InvoiceUpdateParams.cs @@ -12,15 +12,19 @@ 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 +/// cause existing derived classes to break. /// -public sealed record class InvoiceUpdateParams : ParamsBase +public record class InvoiceUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -30,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. @@ -100,6 +119,8 @@ public long? NetTerms public InvoiceUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceUpdateParams(InvoiceUpdateParams invoiceUpdateParams) : base(invoiceUpdateParams) { @@ -107,6 +128,7 @@ public InvoiceUpdateParams(InvoiceUpdateParams invoiceUpdateParams) this._rawBodyData = new(invoiceUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public InvoiceUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -147,6 +169,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +226,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -358,10 +415,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() { @@ -369,7 +426,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class InvoiceUpdateParamsDueDateConverter : JsonConverter @@ -396,7 +466,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) { @@ -590,10 +663,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() { @@ -601,7 +674,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class InvoiceDateConverter : JsonConverter @@ -628,7 +714,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/InvoiceVoidParams.cs b/src/Orb/Models/Invoices/InvoiceVoidParams.cs index 63a9c88ec..22ddb2067 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/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..34fe0816c 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) { @@ -254,6 +260,7 @@ public enum ItemExternalConnectionExternalConnectionName Avalara, Anrok, Numeral, + StripeTax, } sealed class ItemExternalConnectionExternalConnectionNameConverter @@ -275,6 +282,7 @@ JsonSerializerOptions options "avalara" => ItemExternalConnectionExternalConnectionName.Avalara, "anrok" => ItemExternalConnectionExternalConnectionName.Anrok, "numeral" => ItemExternalConnectionExternalConnectionName.Numeral, + "stripe_tax" => ItemExternalConnectionExternalConnectionName.StripeTax, _ => (ItemExternalConnectionExternalConnectionName)(-1), }; } @@ -297,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/ItemArchiveParams.cs b/src/Orb/Models/Items/ItemArchiveParams.cs index 9ae2118ac..5415d4752 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Items/ItemCreateParams.cs b/src/Orb/Models/Items/ItemCreateParams.cs index 53f156719..03f87b7d6 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,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +163,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..aff0bcc4b 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Items/ItemListPage.cs b/src/Orb/Models/Items/ItemListPage.cs index a336efff7..1918e973d 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; @@ -62,5 +63,20 @@ 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) + { + 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/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/ItemListParams.cs b/src/Orb/Models/Items/ItemListParams.cs index 5e12608f0..e3db73528 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,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(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 +135,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..9410a54d1 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +189,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -198,8 +240,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) { @@ -244,6 +289,7 @@ public enum ExternalConnectionName Avalara, Anrok, Numeral, + StripeTax, } sealed class ExternalConnectionNameConverter : JsonConverter @@ -264,6 +310,7 @@ JsonSerializerOptions options "avalara" => ExternalConnectionName.Avalara, "anrok" => ExternalConnectionName.Anrok, "numeral" => ExternalConnectionName.Numeral, + "stripe_tax" => ExternalConnectionName.StripeTax, _ => (ExternalConnectionName)(-1), }; } @@ -286,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/LicenseTypes/LicenseTypeCreateParams.cs b/src/Orb/Models/LicenseTypes/LicenseTypeCreateParams.cs new file mode 100644 index 000000000..b42d63681 --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeCreateParams.cs @@ -0,0 +1,166 @@ +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( + 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 + ); + + 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..c8553b9b2 --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeListPage.cs @@ -0,0 +1,83 @@ +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( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(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..003152120 --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeListParams.cs @@ -0,0 +1,148 @@ +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( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(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..b949fb1fe --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveParams.cs @@ -0,0 +1,121 @@ +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( + 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 + ); + + 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..17c9584ab --- /dev/null +++ b/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParams.cs @@ -0,0 +1,236 @@ +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( + 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 + ); + + 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..8bd55b0a1 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseCreateParams.cs @@ -0,0 +1,200 @@ +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( + 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 + ); + + 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..207fac364 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseDeactivateParams.cs @@ -0,0 +1,162 @@ +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( + 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 + ); + + 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..90a608a0c --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseListPage.cs @@ -0,0 +1,83 @@ +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( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(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..56b953117 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseListParams.cs @@ -0,0 +1,225 @@ +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( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(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..0aac2b226 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDParams.cs @@ -0,0 +1,151 @@ +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( + 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 + ); + + 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..904792843 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseRetrieveParams.cs @@ -0,0 +1,117 @@ +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( + 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 + ); + + 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..643c518f1 --- /dev/null +++ b/src/Orb/Models/Licenses/Usage/UsageGetAllUsageParams.cs @@ -0,0 +1,218 @@ +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( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(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..3b2ecc776 --- /dev/null +++ b/src/Orb/Models/Licenses/Usage/UsageGetUsageParams.cs @@ -0,0 +1,202 @@ +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( + 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 + ); + + 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/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 b0711a9a9..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; @@ -85,18 +87,41 @@ 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); } } + 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() { @@ -106,12 +131,16 @@ public override void Validate() _ = this.Metadata; _ = this.Name; this.Status.Validate(); + _ = this.ParameterDefinitions; } public BillableMetric() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BillableMetric(BillableMetric billableMetric) : base(billableMetric) { } +#pragma warning restore CS8618 public BillableMetric(IReadOnlyDictionary rawData) { @@ -140,7 +169,7 @@ public BillableMetric FromRawUnchecked(IReadOnlyDictionary BillableMetric.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Metrics.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { Active, @@ -148,9 +177,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 +187,22 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "active" => global::Orb.Models.Metrics.Status.Active, - "draft" => global::Orb.Models.Metrics.Status.Draft, - "archived" => global::Orb.Models.Metrics.Status.Archived, - _ => (global::Orb.Models.Metrics.Status)(-1), + "active" => Status.Active, + "draft" => Status.Draft, + "archived" => Status.Archived, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Metrics.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Metrics.Status.Active => "active", - global::Orb.Models.Metrics.Status.Draft => "draft", - global::Orb.Models.Metrics.Status.Archived => "archived", + Status.Active => "active", + Status.Draft => "draft", + Status.Archived => "archived", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Metrics/MetricCreateParams.cs b/src/Orb/Models/Metrics/MetricCreateParams.cs index 2a7de8902..b54cfaa05 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,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +204,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..e2aa73dca 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Metrics/MetricListPage.cs b/src/Orb/Models/Metrics/MetricListPage.cs index 9cdc0abd1..e6f7cd2b5 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; @@ -63,5 +64,20 @@ 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) + { + 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/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/Metrics/MetricListParams.cs b/src/Orb/Models/Metrics/MetricListParams.cs index 8feb4f9e1..d82f93b08 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,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(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 +177,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..e55fa9897 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/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..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,13 +165,17 @@ public override void Validate() item.Validate(); } _ = this.ItemID; + _ = this.LicenseTypeID; _ = this.PerUnitCostBasis; } public NewAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewAllocationPrice(NewAllocationPrice newAllocationPrice) : base(newAllocationPrice) { } +#pragma warning restore CS8618 public NewAllocationPrice(IReadOnlyDictionary rawData) { @@ -308,8 +325,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..99543a224 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,13 +284,17 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingBulkPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingBulkPrice(NewFloatingBulkPrice newFloatingBulkPrice) : base(newFloatingBulkPrice) { } +#pragma warning restore CS8618 public NewFloatingBulkPrice(IReadOnlyDictionary rawData) { @@ -592,10 +609,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() { @@ -603,7 +620,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 5fc419ee5..524dd6717 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,15 +296,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingBulkWithProrationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingBulkWithProrationPrice( NewFloatingBulkWithProrationPrice newFloatingBulkWithProrationPrice ) : base(newFloatingBulkWithProrationPrice) { } +#pragma warning restore CS8618 public NewFloatingBulkWithProrationPrice(IReadOnlyDictionary rawData) { @@ -359,8 +376,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 +460,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) { @@ -771,10 +794,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() { @@ -782,7 +805,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 3f61fd5fc..fee49ca4a 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,15 +296,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingCumulativeGroupedBulkPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingCumulativeGroupedBulkPrice( NewFloatingCumulativeGroupedBulkPrice newFloatingCumulativeGroupedBulkPrice ) : base(newFloatingCumulativeGroupedBulkPrice) { } +#pragma warning restore CS8618 public NewFloatingCumulativeGroupedBulkPrice(IReadOnlyDictionary rawData) { @@ -435,8 +452,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 +543,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) { @@ -788,10 +811,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() { @@ -799,7 +822,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 46ff4e96f..2c51df5dc 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,15 +295,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingGroupedAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingGroupedAllocationPrice( NewFloatingGroupedAllocationPrice newFloatingGroupedAllocationPrice ) : base(newFloatingGroupedAllocationPrice) { } +#pragma warning restore CS8618 public NewFloatingGroupedAllocationPrice(IReadOnlyDictionary rawData) { @@ -437,8 +454,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) { @@ -704,10 +724,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() { @@ -715,7 +735,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 8ff9423a6..c505df50c 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,15 +296,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingGroupedTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingGroupedTieredPackagePrice( NewFloatingGroupedTieredPackagePrice newFloatingGroupedTieredPackagePrice ) : base(newFloatingGroupedTieredPackagePrice) { } +#pragma warning restore CS8618 public NewFloatingGroupedTieredPackagePrice(IReadOnlyDictionary rawData) { @@ -450,8 +467,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 +546,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) { @@ -796,10 +819,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() { @@ -807,7 +830,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 fb2537ca4..8acfc818d 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,15 +291,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingGroupedTieredPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingGroupedTieredPrice( NewFloatingGroupedTieredPrice newFloatingGroupedTieredPrice ) : base(newFloatingGroupedTieredPrice) { } +#pragma warning restore CS8618 public NewFloatingGroupedTieredPrice(IReadOnlyDictionary rawData) { @@ -428,8 +445,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 +518,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) { @@ -764,10 +787,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() { @@ -775,7 +798,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 92cfa8ed4..2a7d0b7b2 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,15 +296,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingGroupedWithMeteredMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingGroupedWithMeteredMinimumPrice( NewFloatingGroupedWithMeteredMinimumPrice newFloatingGroupedWithMeteredMinimumPrice ) : base(newFloatingGroupedWithMeteredMinimumPrice) { } +#pragma warning restore CS8618 public NewFloatingGroupedWithMeteredMinimumPrice( IReadOnlyDictionary rawData @@ -508,10 +525,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 +598,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 +669,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) { @@ -911,10 +937,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() { @@ -922,7 +950,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 2553b6a48..cb4286dce 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,15 +295,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingGroupedWithProratedMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingGroupedWithProratedMinimumPrice( NewFloatingGroupedWithProratedMinimumPrice newFloatingGroupedWithProratedMinimumPrice ) : base(newFloatingGroupedWithProratedMinimumPrice) { } +#pragma warning restore CS8618 public NewFloatingGroupedWithProratedMinimumPrice( IReadOnlyDictionary rawData @@ -445,10 +462,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) { @@ -717,10 +737,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() { @@ -728,7 +748,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 fd77ce172..565360bc1 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,13 +288,17 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingMatrixPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingMatrixPrice(NewFloatingMatrixPrice newFloatingMatrixPrice) : base(newFloatingMatrixPrice) { } +#pragma warning restore CS8618 public NewFloatingMatrixPrice(IReadOnlyDictionary rawData) { @@ -605,10 +622,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() { @@ -616,7 +633,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 4e0dc6133..4e1266ebd 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,15 +295,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingMatrixWithAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingMatrixWithAllocationPrice( NewFloatingMatrixWithAllocationPrice newFloatingMatrixWithAllocationPrice ) : base(newFloatingMatrixWithAllocationPrice) { } +#pragma warning restore CS8618 public NewFloatingMatrixWithAllocationPrice(IReadOnlyDictionary rawData) { @@ -618,10 +635,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() { @@ -629,7 +646,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 2551ddd29..da0e3954a 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,15 +296,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingMatrixWithDisplayNamePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingMatrixWithDisplayNamePrice( NewFloatingMatrixWithDisplayNamePrice newFloatingMatrixWithDisplayNamePrice ) : base(newFloatingMatrixWithDisplayNamePrice) { } +#pragma warning restore CS8618 public NewFloatingMatrixWithDisplayNamePrice(IReadOnlyDictionary rawData) { @@ -438,8 +455,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 +551,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) { @@ -802,10 +825,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() { @@ -813,7 +836,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 3632ec4db..36add6511 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,15 +296,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingMaxGroupTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingMaxGroupTieredPackagePrice( NewFloatingMaxGroupTieredPackagePrice newFloatingMaxGroupTieredPackagePrice ) : base(newFloatingMaxGroupTieredPackagePrice) { } +#pragma warning restore CS8618 public NewFloatingMaxGroupTieredPackagePrice(IReadOnlyDictionary rawData) { @@ -449,8 +466,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 +545,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) { @@ -795,10 +818,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() { @@ -806,7 +829,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 669ffc562..b8e2a0ec2 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,15 +295,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingMinimumCompositePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingMinimumCompositePrice( NewFloatingMinimumCompositePrice newFloatingMinimumCompositePrice ) : base(newFloatingMinimumCompositePrice) { } +#pragma warning restore CS8618 public NewFloatingMinimumCompositePrice(IReadOnlyDictionary rawData) { @@ -431,8 +448,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) { @@ -704,10 +724,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() { @@ -715,7 +735,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 2068ce0d5..433f9fc63 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,13 +288,17 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingPackagePrice(NewFloatingPackagePrice newFloatingPackagePrice) : base(newFloatingPackagePrice) { } +#pragma warning restore CS8618 public NewFloatingPackagePrice(IReadOnlyDictionary rawData) { @@ -605,10 +622,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() { @@ -616,7 +633,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 6b8fea808..52159148b 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,15 +295,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingPackageWithAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingPackageWithAllocationPrice( NewFloatingPackageWithAllocationPrice newFloatingPackageWithAllocationPrice ) : base(newFloatingPackageWithAllocationPrice) { } +#pragma warning restore CS8618 public NewFloatingPackageWithAllocationPrice(IReadOnlyDictionary rawData) { @@ -478,8 +495,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) { @@ -699,10 +719,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() { @@ -710,7 +730,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 d3a79f6ab..ae76e46ab 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,15 +299,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingScalableMatrixWithTieredPricingPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingScalableMatrixWithTieredPricingPrice( NewFloatingScalableMatrixWithTieredPricingPrice newFloatingScalableMatrixWithTieredPricingPrice ) : base(newFloatingScalableMatrixWithTieredPricingPrice) { } +#pragma warning restore CS8618 public NewFloatingScalableMatrixWithTieredPricingPrice( IReadOnlyDictionary rawData @@ -529,10 +546,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 +631,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 +706,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 @@ -913,10 +939,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() { @@ -924,7 +950,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 f44f6d75d..3d9053006 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,15 +299,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingScalableMatrixWithUnitPricingPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingScalableMatrixWithUnitPricingPrice( NewFloatingScalableMatrixWithUnitPricingPrice newFloatingScalableMatrixWithUnitPricingPrice ) : base(newFloatingScalableMatrixWithUnitPricingPrice) { } +#pragma warning restore CS8618 public NewFloatingScalableMatrixWithUnitPricingPrice( IReadOnlyDictionary rawData @@ -493,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 /// @@ -528,16 +558,20 @@ public override void Validate() 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) { @@ -620,10 +654,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 @@ -850,10 +887,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() { @@ -861,7 +898,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 460aa1a06..f872dbf16 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,15 +296,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingThresholdTotalAmountPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingThresholdTotalAmountPrice( NewFloatingThresholdTotalAmountPrice newFloatingThresholdTotalAmountPrice ) : base(newFloatingThresholdTotalAmountPrice) { } +#pragma warning restore CS8618 public NewFloatingThresholdTotalAmountPrice(IReadOnlyDictionary rawData) { @@ -486,8 +503,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 +584,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) { @@ -784,10 +807,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() { @@ -795,7 +818,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 c62715c8d..6d76e8ac9 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,15 +291,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingTieredPackagePrice( NewFloatingTieredPackagePrice newFloatingTieredPackagePrice ) : base(newFloatingTieredPackagePrice) { } +#pragma warning restore CS8618 public NewFloatingTieredPackagePrice(IReadOnlyDictionary rawData) { @@ -473,8 +490,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 +563,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) { @@ -764,10 +787,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() { @@ -775,7 +798,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 b3b286c01..bc4f3f7fd 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,15 +296,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingTieredPackageWithMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingTieredPackageWithMinimumPrice( NewFloatingTieredPackageWithMinimumPrice newFloatingTieredPackageWithMinimumPrice ) : base(newFloatingTieredPackageWithMinimumPrice) { } +#pragma warning restore CS8618 public NewFloatingTieredPackageWithMinimumPrice( IReadOnlyDictionary rawData @@ -488,10 +505,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 +594,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) { @@ -797,10 +820,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() { @@ -808,7 +833,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 cd30975f6..11a7211fc 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,13 +288,17 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingTieredPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingTieredPrice(NewFloatingTieredPrice newFloatingTieredPrice) : base(newFloatingTieredPrice) { } +#pragma warning restore CS8618 public NewFloatingTieredPrice(IReadOnlyDictionary rawData) { @@ -605,10 +622,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() { @@ -616,7 +633,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 bf420bab6..93a5fb2df 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,15 +296,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingTieredWithMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingTieredWithMinimumPrice( NewFloatingTieredWithMinimumPrice newFloatingTieredWithMinimumPrice ) : base(newFloatingTieredWithMinimumPrice) { } +#pragma warning restore CS8618 public NewFloatingTieredWithMinimumPrice(IReadOnlyDictionary rawData) { @@ -512,8 +529,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 +623,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) { @@ -824,10 +847,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() { @@ -835,7 +858,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 1b20ff274..14ae918be 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,15 +296,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingTieredWithProrationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingTieredWithProrationPrice( NewFloatingTieredWithProrationPrice newFloatingTieredWithProrationPrice ) : base(newFloatingTieredWithProrationPrice) { } +#pragma warning restore CS8618 public NewFloatingTieredWithProrationPrice(IReadOnlyDictionary rawData) { @@ -471,8 +488,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 +574,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) { @@ -777,10 +800,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() { @@ -788,7 +811,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 a682455b4..30799101d 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,13 +288,17 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingUnitPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingUnitPrice(NewFloatingUnitPrice newFloatingUnitPrice) : base(newFloatingUnitPrice) { } +#pragma warning restore CS8618 public NewFloatingUnitPrice(IReadOnlyDictionary rawData) { @@ -604,10 +621,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() { @@ -615,7 +632,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 c70ae8b52..b7fc477d5 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,15 +293,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingUnitWithPercentPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingUnitWithPercentPrice( NewFloatingUnitWithPercentPrice newFloatingUnitWithPercentPrice ) : base(newFloatingUnitWithPercentPrice) { } +#pragma warning restore CS8618 public NewFloatingUnitWithPercentPrice(IReadOnlyDictionary rawData) { @@ -466,8 +483,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) { @@ -687,10 +707,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() { @@ -698,7 +718,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 1e6e13504..f99519846 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,15 +295,19 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } public NewFloatingUnitWithProrationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewFloatingUnitWithProrationPrice( NewFloatingUnitWithProrationPrice newFloatingUnitWithProrationPrice ) : base(newFloatingUnitWithProrationPrice) { } +#pragma warning restore CS8618 public NewFloatingUnitWithProrationPrice(IReadOnlyDictionary rawData) { @@ -455,8 +472,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) { @@ -683,10 +703,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() { @@ -694,7 +714,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewFloatingUnitWithProrationPriceConversionRateConfigConverter 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..8f6845d2a 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,14 +303,18 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanBulkPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanBulkPrice(NewPlanBulkPrice newPlanBulkPrice) : base(newPlanBulkPrice) { } +#pragma warning restore CS8618 public NewPlanBulkPrice(IReadOnlyDictionary rawData) { @@ -619,10 +636,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() { @@ -630,7 +647,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 cb43ff72a..594951c74 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,16 +308,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanBulkWithProrationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanBulkWithProrationPrice( NewPlanBulkWithProrationPrice newPlanBulkWithProrationPrice ) : base(newPlanBulkWithProrationPrice) { } +#pragma warning restore CS8618 public NewPlanBulkWithProrationPrice(IReadOnlyDictionary rawData) { @@ -378,10 +395,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 +493,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 @@ -813,10 +836,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() { @@ -824,7 +847,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 31e8ea177..13f1796e8 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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanCumulativeGroupedBulkPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanCumulativeGroupedBulkPrice( NewPlanCumulativeGroupedBulkPrice newPlanCumulativeGroupedBulkPrice ) : base(newPlanCumulativeGroupedBulkPrice) { } +#pragma warning restore CS8618 public NewPlanCumulativeGroupedBulkPrice(IReadOnlyDictionary rawData) { @@ -452,10 +469,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 +573,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 @@ -831,10 +854,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() { @@ -842,7 +865,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 d35081227..69092c99f 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,16 +307,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanGroupedAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedAllocationPrice( NewPlanGroupedAllocationPrice newPlanGroupedAllocationPrice ) : base(newPlanGroupedAllocationPrice) { } +#pragma warning restore CS8618 public NewPlanGroupedAllocationPrice(IReadOnlyDictionary rawData) { @@ -455,10 +472,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 @@ -728,10 +748,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() { @@ -739,7 +759,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 be0dd80d3..3bf39bab7 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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanGroupedTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedTieredPackagePrice( NewPlanGroupedTieredPackagePrice newPlanGroupedTieredPackagePrice ) : base(newPlanGroupedTieredPackagePrice) { } +#pragma warning restore CS8618 public NewPlanGroupedTieredPackagePrice(IReadOnlyDictionary rawData) { @@ -467,10 +484,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 +571,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 @@ -826,10 +849,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() { @@ -837,7 +860,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 3db6af5e1..99151c805 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,14 +308,18 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanGroupedTieredPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedTieredPrice(NewPlanGroupedTieredPrice newPlanGroupedTieredPrice) : base(newPlanGroupedTieredPrice) { } +#pragma warning restore CS8618 public NewPlanGroupedTieredPrice(IReadOnlyDictionary rawData) { @@ -451,10 +468,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 +552,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 @@ -803,10 +826,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() { @@ -814,7 +837,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 c6918497f..bf922c8a3 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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanGroupedWithMeteredMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedWithMeteredMinimumPrice( NewPlanGroupedWithMeteredMinimumPrice newPlanGroupedWithMeteredMinimumPrice ) : base(newPlanGroupedWithMeteredMinimumPrice) { } +#pragma warning restore CS8618 public NewPlanGroupedWithMeteredMinimumPrice(IReadOnlyDictionary rawData) { @@ -525,10 +542,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 +629,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 +720,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 @@ -975,10 +1001,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() { @@ -986,7 +1012,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 9ba2bc2da..9af79b439 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,16 +310,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanGroupedWithProratedMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanGroupedWithProratedMinimumPrice( NewPlanGroupedWithProratedMinimumPrice newPlanGroupedWithProratedMinimumPrice ) : base(newPlanGroupedWithProratedMinimumPrice) { } +#pragma warning restore CS8618 public NewPlanGroupedWithProratedMinimumPrice(IReadOnlyDictionary rawData) { @@ -460,10 +477,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 @@ -738,10 +758,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() { @@ -749,7 +769,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 2c6adbee7..35a4bb8a6 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,14 +303,18 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanMatrixPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanMatrixPrice(NewPlanMatrixPrice newPlanMatrixPrice) : base(newPlanMatrixPrice) { } +#pragma warning restore CS8618 public NewPlanMatrixPrice(IReadOnlyDictionary rawData) { @@ -619,10 +636,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() { @@ -630,7 +647,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 bd0f72c43..3e107b24f 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,16 +310,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanMatrixWithAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanMatrixWithAllocationPrice( NewPlanMatrixWithAllocationPrice newPlanMatrixWithAllocationPrice ) : base(newPlanMatrixWithAllocationPrice) { } +#pragma warning restore CS8618 public NewPlanMatrixWithAllocationPrice(IReadOnlyDictionary rawData) { @@ -633,10 +650,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() { @@ -644,7 +661,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 b399edc20..e2af5fbd8 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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanMatrixWithDisplayNamePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanMatrixWithDisplayNamePrice( NewPlanMatrixWithDisplayNamePrice newPlanMatrixWithDisplayNamePrice ) : base(newPlanMatrixWithDisplayNamePrice) { } +#pragma warning restore CS8618 public NewPlanMatrixWithDisplayNamePrice(IReadOnlyDictionary rawData) { @@ -455,10 +472,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 +576,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 @@ -834,10 +857,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() { @@ -845,7 +868,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 f67602ebf..4ae03ff60 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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanMaxGroupTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanMaxGroupTieredPackagePrice( NewPlanMaxGroupTieredPackagePrice newPlanMaxGroupTieredPackagePrice ) : base(newPlanMaxGroupTieredPackagePrice) { } +#pragma warning restore CS8618 public NewPlanMaxGroupTieredPackagePrice(IReadOnlyDictionary rawData) { @@ -466,10 +483,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 +570,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 @@ -825,10 +848,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() { @@ -836,7 +859,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 75f339dea..009bf292a 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,14 +307,18 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanMinimumCompositePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanMinimumCompositePrice(NewPlanMinimumCompositePrice newPlanMinimumCompositePrice) : base(newPlanMinimumCompositePrice) { } +#pragma warning restore CS8618 public NewPlanMinimumCompositePrice(IReadOnlyDictionary rawData) { @@ -447,10 +464,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 @@ -727,10 +747,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() { @@ -738,7 +758,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 f0ff05d76..4dd509cb7 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,14 +303,18 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanPackagePrice(NewPlanPackagePrice newPlanPackagePrice) : base(newPlanPackagePrice) { } +#pragma warning restore CS8618 public NewPlanPackagePrice(IReadOnlyDictionary rawData) { @@ -619,10 +636,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() { @@ -630,7 +647,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 b5c7793dd..8c3b564b8 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,16 +310,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanPackageWithAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanPackageWithAllocationPrice( NewPlanPackageWithAllocationPrice newPlanPackageWithAllocationPrice ) : base(newPlanPackageWithAllocationPrice) { } +#pragma warning restore CS8618 public NewPlanPackageWithAllocationPrice(IReadOnlyDictionary rawData) { @@ -496,10 +513,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 @@ -724,10 +744,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() { @@ -735,7 +755,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 706da7ca1..1af581809 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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanScalableMatrixWithTieredPricingPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanScalableMatrixWithTieredPricingPrice( NewPlanScalableMatrixWithTieredPricingPrice newPlanScalableMatrixWithTieredPricingPrice ) : base(newPlanScalableMatrixWithTieredPricingPrice) { } +#pragma warning restore CS8618 public NewPlanScalableMatrixWithTieredPricingPrice( IReadOnlyDictionary rawData @@ -541,10 +558,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 +657,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 +747,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 @@ -958,10 +984,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() { @@ -969,7 +995,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 b04312f7c..458db8a0d 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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanScalableMatrixWithUnitPricingPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanScalableMatrixWithUnitPricingPrice( NewPlanScalableMatrixWithUnitPricingPrice newPlanScalableMatrixWithUnitPricingPrice ) : base(newPlanScalableMatrixWithUnitPricingPrice) { } +#pragma warning restore CS8618 public NewPlanScalableMatrixWithUnitPricingPrice( IReadOnlyDictionary rawData @@ -507,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 /// @@ -542,16 +572,20 @@ public override void Validate() item.Validate(); } _ = this.UnitPrice; + _ = this.GroupingKey; _ = this.Prorate; _ = this.SecondDimension; } public NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfig( NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfig newPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfig ) : base(newPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfig) { } +#pragma warning restore CS8618 public NewPlanScalableMatrixWithUnitPricingPriceScalableMatrixWithUnitPricingConfig( IReadOnlyDictionary rawData @@ -644,12 +678,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 @@ -877,10 +914,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() { @@ -888,7 +927,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 81d882f08..549491ed8 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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanThresholdTotalAmountPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanThresholdTotalAmountPrice( NewPlanThresholdTotalAmountPrice newPlanThresholdTotalAmountPrice ) : base(newPlanThresholdTotalAmountPrice) { } +#pragma warning restore CS8618 public NewPlanThresholdTotalAmountPrice(IReadOnlyDictionary rawData) { @@ -503,10 +520,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 +616,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 @@ -827,10 +850,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() { @@ -838,7 +861,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 85d60c7c5..8d64e73de 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,14 +308,18 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanTieredPackagePrice(NewPlanTieredPackagePrice newPlanTieredPackagePrice) : base(newPlanTieredPackagePrice) { } +#pragma warning restore CS8618 public NewPlanTieredPackagePrice(IReadOnlyDictionary rawData) { @@ -496,10 +513,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 +597,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 @@ -803,10 +826,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() { @@ -814,7 +837,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 b17f910c3..07a30325b 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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanTieredPackageWithMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanTieredPackageWithMinimumPrice( NewPlanTieredPackageWithMinimumPrice newPlanTieredPackageWithMinimumPrice ) : base(newPlanTieredPackageWithMinimumPrice) { } +#pragma warning restore CS8618 public NewPlanTieredPackageWithMinimumPrice(IReadOnlyDictionary rawData) { @@ -502,10 +519,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 +617,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 @@ -828,10 +851,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() { @@ -839,7 +862,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 6239140f3..09b829fa3 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,14 +303,18 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanTieredPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanTieredPrice(NewPlanTieredPrice newPlanTieredPrice) : base(newPlanTieredPrice) { } +#pragma warning restore CS8618 public NewPlanTieredPrice(IReadOnlyDictionary rawData) { @@ -619,10 +636,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() { @@ -630,7 +647,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 4228c73c2..bf5704e33 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,16 +308,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanTieredWithMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanTieredWithMinimumPrice( NewPlanTieredWithMinimumPrice newPlanTieredWithMinimumPrice ) : base(newPlanTieredWithMinimumPrice) { } +#pragma warning restore CS8618 public NewPlanTieredWithMinimumPrice(IReadOnlyDictionary rawData) { @@ -528,10 +545,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 +651,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 @@ -859,10 +882,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() { @@ -870,7 +893,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 3f2ea1262..53e74bb28 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,14 +303,18 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanUnitPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanUnitPrice(NewPlanUnitPrice newPlanUnitPrice) : base(newPlanUnitPrice) { } +#pragma warning restore CS8618 public NewPlanUnitPrice(IReadOnlyDictionary rawData) { @@ -619,10 +636,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() { @@ -630,7 +647,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 6c235d3e5..69a5ac116 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,14 +307,18 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanUnitWithPercentPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanUnitWithPercentPrice(NewPlanUnitWithPercentPrice newPlanUnitWithPercentPrice) : base(newPlanUnitWithPercentPrice) { } +#pragma warning restore CS8618 public NewPlanUnitWithPercentPrice(IReadOnlyDictionary rawData) { @@ -484,10 +501,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 @@ -710,10 +730,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() { @@ -721,7 +741,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 e830a05e9..91a2adfc4 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,16 +307,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewPlanUnitWithProrationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewPlanUnitWithProrationPrice( NewPlanUnitWithProrationPrice newPlanUnitWithProrationPrice ) : base(newPlanUnitWithProrationPrice) { } +#pragma warning restore CS8618 public NewPlanUnitWithProrationPrice(IReadOnlyDictionary rawData) { @@ -472,10 +489,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 @@ -707,10 +727,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() { @@ -718,7 +738,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class NewPlanUnitWithProrationPriceConversionRateConfigConverter 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/ExternalPlanID/ExternalPlanIDFetchParams.cs b/src/Orb/Models/Plans/ExternalPlanID/ExternalPlanIDFetchParams.cs index 379ba1c88..5ce6fefb5 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +123,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..0671158bd 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,41 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Plans/Migrations/MigrationCancelParams.cs b/src/Orb/Models/Plans/Migrations/MigrationCancelParams.cs index 3c14d6e9c..e09dca740 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,36 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Plans/Migrations/MigrationCancelResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs index 7b94ca3c8..032fe45c5 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) { @@ -344,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() { @@ -355,7 +358,21 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + ApiEnum _ => 2, + _ => -1, + }; + } } sealed class MigrationCancelResponseEffectiveTimeConverter @@ -399,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) { diff --git a/src/Orb/Models/Plans/Migrations/MigrationListPage.cs b/src/Orb/Models/Plans/Migrations/MigrationListPage.cs index 5b715d8e1..72e56f689 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; @@ -63,5 +64,20 @@ 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) + { + 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/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/MigrationListParams.cs b/src/Orb/Models/Plans/Migrations/MigrationListParams.cs index 9968d05b6..5b2708f89 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Plans/Migrations/MigrationListResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationListResponse.cs index 7188e8f9e..00a80b478 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) { @@ -343,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() { @@ -354,7 +357,21 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + ApiEnum _ => 2, + _ => -1, + }; + } } sealed class MigrationListResponseEffectiveTimeConverter @@ -398,7 +415,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/MigrationRetrieveParams.cs b/src/Orb/Models/Plans/Migrations/MigrationRetrieveParams.cs index 03ee5e28c..c8043498b 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,36 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Plans/Migrations/MigrationRetrieveResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs index 79e6faa81..1298672a5 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); } } @@ -67,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) { @@ -316,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() { @@ -327,7 +328,21 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + ApiEnum _ => 2, + _ => -1, + }; + } } sealed class EffectiveTimeConverter : JsonConverter @@ -371,7 +386,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) { @@ -432,7 +450,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Plans.Migrations.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { NotStarted, @@ -442,9 +460,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 +470,26 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "not_started" => global::Orb.Models.Plans.Migrations.Status.NotStarted, - "in_progress" => global::Orb.Models.Plans.Migrations.Status.InProgress, - "completed" => global::Orb.Models.Plans.Migrations.Status.Completed, - "action_needed" => global::Orb.Models.Plans.Migrations.Status.ActionNeeded, - "canceled" => global::Orb.Models.Plans.Migrations.Status.Canceled, - _ => (global::Orb.Models.Plans.Migrations.Status)(-1), + "not_started" => Status.NotStarted, + "in_progress" => Status.InProgress, + "completed" => Status.Completed, + "action_needed" => Status.ActionNeeded, + "canceled" => Status.Canceled, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Plans.Migrations.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Plans.Migrations.Status.NotStarted => "not_started", - global::Orb.Models.Plans.Migrations.Status.InProgress => "in_progress", - global::Orb.Models.Plans.Migrations.Status.Completed => "completed", - global::Orb.Models.Plans.Migrations.Status.ActionNeeded => "action_needed", - global::Orb.Models.Plans.Migrations.Status.Canceled => "canceled", + Status.NotStarted => "not_started", + Status.InProgress => "in_progress", + Status.Completed => "completed", + Status.ActionNeeded => "action_needed", + Status.Canceled => "canceled", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Plans/Plan.cs b/src/Orb/Models/Plans/Plan.cs index b0a7fea4e..c529d290f 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); } } @@ -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" @@ -810,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() { @@ -821,7 +824,23 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 @@ -1030,8 +1049,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) { @@ -1139,12 +1161,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); } } @@ -1200,8 +1222,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 +1351,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 +1465,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 16b4882a9..9bc44d795 100644 --- a/src/Orb/Models/Plans/PlanCreateParams.cs +++ b/src/Orb/Models/Plans/PlanCreateParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Plans; /// /// This endpoint allows creation of plans including their prices. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PlanCreateParams : ParamsBase +public record class PlanCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -50,18 +54,16 @@ public required string Name /// Prices for this plan. If the plan has phases, this includes prices across /// all phases of the plan. /// - public required IReadOnlyList Prices + public required IReadOnlyList Prices { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullStruct< - ImmutableArray - >("prices"); + return this._rawBodyData.GetNotNullStruct>("prices"); } init { - this._rawBodyData.Set>( + this._rawBodyData.Set>( "prices", ImmutableArray.ToImmutableArray(value) ); @@ -72,18 +74,16 @@ public required string Name /// Adjustments for this plan. If the plan has phases, this includes adjustments /// across all phases of the plan. /// - public IReadOnlyList? Adjustments + public IReadOnlyList? Adjustments { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableStruct< - ImmutableArray - >("adjustments"); + return this._rawBodyData.GetNullableStruct>("adjustments"); } init { - this._rawBodyData.Set?>( + this._rawBodyData.Set?>( "adjustments", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -175,14 +175,12 @@ public IReadOnlyList? PlanPhases /// The status of the plan to create (either active or draft). If not specified, /// this defaults to active. /// - public ApiEnum? Status + public ApiEnum? Status { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNullableClass< - ApiEnum - >("status"); + return this._rawBodyData.GetNullableClass>("status"); } init { @@ -197,11 +195,14 @@ public IReadOnlyList? PlanPhases public PlanCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanCreateParams(PlanCreateParams planCreateParams) : base(planCreateParams) { this._rawBodyData = new(planCreateParams._rawBodyData); } +#pragma warning restore CS8618 public PlanCreateParams( IReadOnlyDictionary rawHeaderData, @@ -242,6 +243,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + public virtual bool Equals(PlanCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/plans") @@ -267,9 +296,14 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter(typeof(JsonModelConverter))] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Price : JsonModel { /// @@ -285,6 +319,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. /// @@ -315,14 +364,18 @@ public PricePrice? PriceValue public override void Validate() { this.AllocationPrice?.Validate(); + this.LicenseAllocationPrice?.Validate(); _ = this.PlanPhaseOrder; this.PriceValue?.Validate(); } public Price() { } - public Price(global::Orb.Models.Plans.Price price) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Price(Price price) : base(price) { } +#pragma warning restore CS8618 public Price(IReadOnlyDictionary rawData) { @@ -338,27 +391,24 @@ 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); } /// -/// New plan price request body params. +/// The license allocation price to add to the plan. /// -[JsonConverter(typeof(PricePriceConverter))] -public record class PricePrice : ModelBase +[JsonConverter(typeof(LicenseAllocationPriceConverter))] +public record class LicenseAllocationPrice : ModelBase { public object? Value { get; } = null; @@ -380,77 +430,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, - minimum: (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, - minimum: (x) => x.Name, - newPlanMinimumComposite: (x) => x.Name, + minimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name ); @@ -462,36 +550,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, - minimum: (x) => x.BillableMetricID, - newPlanMinimumComposite: (x) => x.BillableMetricID, + minimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID ); @@ -503,36 +590,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, - minimum: (x) => x.BilledInAdvance, - newPlanMinimumComposite: (x) => x.BilledInAdvance, + minimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance ); @@ -544,36 +630,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, - minimum: (x) => x.BillingCycleConfiguration, - newPlanMinimumComposite: (x) => x.BillingCycleConfiguration, + minimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration ); @@ -585,36 +670,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, - minimum: (x) => x.ConversionRate, - newPlanMinimumComposite: (x) => x.ConversionRate, + minimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate ); @@ -626,36 +710,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, - minimum: (x) => x.Currency, - newPlanMinimumComposite: (x) => x.Currency, + minimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency ); @@ -667,36 +750,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, - minimum: (x) => x.DimensionalPriceConfiguration, - newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, + minimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration ); @@ -708,36 +790,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, - minimum: (x) => x.ExternalPriceID, - newPlanMinimumComposite: (x) => x.ExternalPriceID, + minimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID ); @@ -749,36 +830,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, - minimum: (x) => x.FixedPriceQuantity, - newPlanMinimumComposite: (x) => x.FixedPriceQuantity, + minimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity ); @@ -790,36 +870,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, - minimum: (x) => x.InvoiceGroupingKey, - newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, + minimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey ); @@ -831,241 +910,273 @@ 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, - minimum: (x) => x.InvoicingCycleConfiguration, - newPlanMinimumComposite: (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( - 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, - minimum: (x) => x.ReferenceID, - newPlanMinimumComposite: (x) => x.ReferenceID, + minimumComposite: (x) => x.ReferenceID, percent: (x) => x.ReferenceID, eventOutput: (x) => x.ReferenceID ); } } - public PricePrice(NewPlanUnitPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Unit value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanTieredPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Tiered value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanBulkPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Bulk value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(global::Orb.Models.Plans.BulkWithFilters value, JsonElement? element = null) + public LicenseAllocationPrice(BulkWithFilters value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(Package value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanMatrixPrice value, JsonElement? element = null) + public LicenseAllocationPrice(Matrix value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) + public LicenseAllocationPrice(ThresholdTotalAmount value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanTieredPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredPackage value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredWithMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanGroupedTieredPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedTiered value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanTieredPackageWithMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(TieredPackageWithMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(PackageWithAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanUnitWithPercentPrice value, JsonElement? element = null) + public LicenseAllocationPrice(UnitWithPercent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(MatrixWithAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice( - global::Orb.Models.Plans.TieredWithProration value, - JsonElement? element = null - ) + public LicenseAllocationPrice(TieredWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanUnitWithProrationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(UnitWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanGroupedAllocationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanBulkWithProrationPrice value, JsonElement? element = null) + public LicenseAllocationPrice(BulkWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanGroupedWithProratedMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedWithProratedMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanGroupedWithMeteredMinimumPrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedWithMeteredMinimum value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice( - global::Orb.Models.Plans.GroupedWithMinMaxThresholds value, - JsonElement? element = null - ) + public LicenseAllocationPrice(GroupedWithMinMaxThresholds value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) + public LicenseAllocationPrice(MatrixWithDisplayName value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(GroupedTieredPackage value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) + public LicenseAllocationPrice(MaxGroupTieredPackage value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanScalableMatrixWithUnitPricingPrice value, JsonElement? element = null) + public LicenseAllocationPrice(ScalableMatrixWithUnitPricing value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value, + public LicenseAllocationPrice( + ScalableMatrixWithTieredPricing value, JsonElement? element = null ) { @@ -1073,769 +1184,703 @@ public PricePrice( this._element = element; } - public PricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public PricePrice( - global::Orb.Models.Plans.CumulativeGroupedAllocation value, - JsonElement? element = null - ) + public LicenseAllocationPrice(CumulativeGroupedBulk value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(global::Orb.Models.Plans.Minimum value, JsonElement? element = null) + public LicenseAllocationPrice(CumulativeGroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) + public LicenseAllocationPrice(MinimumComposite value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(global::Orb.Models.Plans.Percent value, JsonElement? element = null) + public LicenseAllocationPrice(Percent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(global::Orb.Models.Plans.EventOutput value, JsonElement? element = null) + public LicenseAllocationPrice(EventOutput value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PricePrice(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; } /// /// 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; } /// /// 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; } /// /// 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; } /// /// 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; } /// /// 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; } /// /// 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; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `global::Orb.Models.Plans.CumulativeGroupedAllocation` + /// // `value` is of type `CumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out global::Orb.Models.Plans.CumulativeGroupedAllocation? value + [NotNullWhen(true)] out CumulativeGroupedAllocation? value ) { - value = this.Value as global::Orb.Models.Plans.CumulativeGroupedAllocation; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Plans.Minimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out global::Orb.Models.Plans.Minimum? value) - { - value = this.Value as global::Orb.Models.Plans.Minimum; + value = this.Value as CumulativeGroupedAllocation; return value != null; } /// /// 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; } /// /// 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; } @@ -1853,177 +1898,174 @@ public bool TryPickEventOutput( /// /// /// instance.Switch( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Plans.BulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Plans.TieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Plans.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) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Plans.Percent value) => {...}, - /// (global::Orb.Models.Plans.EventOutput value) => {...} + /// (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 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 + 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 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 global::Orb.Models.Plans.BulkWithFilters value: + 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 global::Orb.Models.Plans.TieredWithProration value: + 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 global::Orb.Models.Plans.GroupedWithMinMaxThresholds value: + 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 global::Orb.Models.Plans.CumulativeGroupedAllocation value: + case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case global::Orb.Models.Plans.Minimum value: - minimum(value); + case MinimumComposite value: + minimumComposite(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: - throw new OrbInvalidDataException("Data did not match any variant of PricePrice"); + throw new OrbInvalidDataException( + "Data did not match any variant of LicenseAllocationPrice" + ); } } @@ -2042,219 +2084,189 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Plans.BulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Plans.TieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Plans.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) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Plans.Percent value) => {...}, - /// (global::Orb.Models.Plans.EventOutput value) => {...} + /// (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 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< - global::Orb.Models.Plans.GroupedWithMinMaxThresholds, - T - > groupedWithMinMaxThresholds, - System::Func newPlanMatrixWithDisplayName, - System::Func newPlanGroupedTieredPackage, - System::Func newPlanMaxGroupTieredPackage, - System::Func< - NewPlanScalableMatrixWithUnitPricingPrice, - T - > newPlanScalableMatrixWithUnitPricing, - System::Func< - NewPlanScalableMatrixWithTieredPricingPrice, - T - > newPlanScalableMatrixWithTieredPricing, - System::Func newPlanCumulativeGroupedBulk, - System::Func< - global::Orb.Models.Plans.CumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, - System::Func newPlanMinimumComposite, - System::Func percent, - System::Func eventOutput + 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 { - NewPlanUnitPrice value => newPlanUnit(value), - NewPlanTieredPrice value => newPlanTiered(value), - NewPlanBulkPrice value => newPlanBulk(value), - global::Orb.Models.Plans.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), - global::Orb.Models.Plans.TieredWithProration value => tieredWithProration(value), - NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), - NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), - NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), - NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( - value - ), - NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), - global::Orb.Models.Plans.GroupedWithMinMaxThresholds value => - groupedWithMinMaxThresholds(value), - NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), - NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), - NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), - NewPlanScalableMatrixWithUnitPricingPrice value => newPlanScalableMatrixWithUnitPricing( - value + 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" ), - NewPlanScalableMatrixWithTieredPricingPrice value => - newPlanScalableMatrixWithTieredPricing(value), - NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), - global::Orb.Models.Plans.CumulativeGroupedAllocation value => - cumulativeGroupedAllocation(value), - global::Orb.Models.Plans.Minimum value => minimum(value), - NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), - global::Orb.Models.Plans.Percent value => percent(value), - global::Orb.Models.Plans.EventOutput value => eventOutput(value), - _ => throw new OrbInvalidDataException("Data did not match any variant of PricePrice"), }; } - public static implicit operator PricePrice(NewPlanUnitPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(Unit value) => new(value); - public static implicit operator PricePrice(NewPlanTieredPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(Tiered value) => new(value); - public static implicit operator PricePrice(NewPlanBulkPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(Bulk value) => new(value); - public static implicit operator PricePrice(global::Orb.Models.Plans.BulkWithFilters value) => - new(value); + public static implicit operator LicenseAllocationPrice(BulkWithFilters value) => new(value); - public static implicit operator PricePrice(NewPlanPackagePrice value) => new(value); + public static implicit operator LicenseAllocationPrice(Package value) => new(value); - public static implicit operator PricePrice(NewPlanMatrixPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(Matrix value) => new(value); - public static implicit operator PricePrice(NewPlanThresholdTotalAmountPrice value) => + public static implicit operator LicenseAllocationPrice(ThresholdTotalAmount value) => new(value); - public static implicit operator PricePrice(NewPlanTieredPackagePrice value) => new(value); + public static implicit operator LicenseAllocationPrice(TieredPackage value) => new(value); - public static implicit operator PricePrice(NewPlanTieredWithMinimumPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(TieredWithMinimum value) => new(value); - public static implicit operator PricePrice(NewPlanGroupedTieredPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedTiered value) => new(value); - public static implicit operator PricePrice(NewPlanTieredPackageWithMinimumPrice value) => + public static implicit operator LicenseAllocationPrice(TieredPackageWithMinimum value) => new(value); - public static implicit operator PricePrice(NewPlanPackageWithAllocationPrice value) => + public static implicit operator LicenseAllocationPrice(PackageWithAllocation value) => new(value); - public static implicit operator PricePrice(NewPlanUnitWithPercentPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(UnitWithPercent value) => new(value); - public static implicit operator PricePrice(NewPlanMatrixWithAllocationPrice value) => + public static implicit operator LicenseAllocationPrice(MatrixWithAllocation value) => new(value); - public static implicit operator PricePrice( - global::Orb.Models.Plans.TieredWithProration value - ) => new(value); + public static implicit operator LicenseAllocationPrice(TieredWithProration value) => new(value); - public static implicit operator PricePrice(NewPlanUnitWithProrationPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(UnitWithProration value) => new(value); - public static implicit operator PricePrice(NewPlanGroupedAllocationPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(GroupedAllocation value) => new(value); - public static implicit operator PricePrice(NewPlanBulkWithProrationPrice value) => new(value); + public static implicit operator LicenseAllocationPrice(BulkWithProration value) => new(value); - public static implicit operator PricePrice(NewPlanGroupedWithProratedMinimumPrice value) => + public static implicit operator LicenseAllocationPrice(GroupedWithProratedMinimum value) => new(value); - public static implicit operator PricePrice(NewPlanGroupedWithMeteredMinimumPrice value) => + public static implicit operator LicenseAllocationPrice(GroupedWithMeteredMinimum value) => new(value); - public static implicit operator PricePrice( - global::Orb.Models.Plans.GroupedWithMinMaxThresholds value - ) => new(value); - - public static implicit operator PricePrice(NewPlanMatrixWithDisplayNamePrice value) => + public static implicit operator LicenseAllocationPrice(GroupedWithMinMaxThresholds value) => new(value); - public static implicit operator PricePrice(NewPlanGroupedTieredPackagePrice value) => + public static implicit operator LicenseAllocationPrice(MatrixWithDisplayName value) => new(value); - public static implicit operator PricePrice(NewPlanMaxGroupTieredPackagePrice value) => + public static implicit operator LicenseAllocationPrice(GroupedTieredPackage value) => new(value); - public static implicit operator PricePrice(NewPlanScalableMatrixWithUnitPricingPrice value) => + public static implicit operator LicenseAllocationPrice(MaxGroupTieredPackage value) => new(value); - public static implicit operator PricePrice(NewPlanScalableMatrixWithTieredPricingPrice value) => + public static implicit operator LicenseAllocationPrice(ScalableMatrixWithUnitPricing value) => new(value); - public static implicit operator PricePrice(NewPlanCumulativeGroupedBulkPrice value) => + public static implicit operator LicenseAllocationPrice(ScalableMatrixWithTieredPricing value) => new(value); - public static implicit operator PricePrice( - global::Orb.Models.Plans.CumulativeGroupedAllocation value - ) => new(value); + public static implicit operator LicenseAllocationPrice(CumulativeGroupedBulk value) => + new(value); - public static implicit operator PricePrice(global::Orb.Models.Plans.Minimum value) => + public static implicit operator LicenseAllocationPrice(CumulativeGroupedAllocation value) => new(value); - public static implicit operator PricePrice(NewPlanMinimumCompositePrice value) => new(value); + public static implicit operator LicenseAllocationPrice(MinimumComposite value) => new(value); - public static implicit operator PricePrice(global::Orb.Models.Plans.Percent value) => - new(value); + public static implicit operator LicenseAllocationPrice(Percent value) => new(value); - public static implicit operator PricePrice(global::Orb.Models.Plans.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 @@ -2270,50 +2282,49 @@ public override void Validate() { if (this.Value == null) { - throw new OrbInvalidDataException("Data did not match any variant of PricePrice"); + 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(), - (minimum) => minimum.Validate(), - (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), + (minimumComposite) => minimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() ); } - public virtual bool Equals(PricePrice? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(LicenseAllocationPrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2321,12 +2332,54 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + 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 PricePriceConverter : JsonConverter +sealed class LicenseAllocationPriceConverter : JsonConverter { - public override PricePrice? Read( + public override LicenseAllocationPrice? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2349,10 +2402,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2371,10 +2421,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2393,10 +2440,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2415,11 +2459,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2438,10 +2481,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2460,10 +2500,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2482,7 +2519,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -2504,10 +2541,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2526,7 +2560,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -2548,10 +2582,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2570,11 +2601,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2593,11 +2623,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2616,7 +2645,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -2638,7 +2667,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -2660,11 +2689,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2683,7 +2711,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -2705,7 +2733,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -2727,7 +2755,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -2749,11 +2777,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2772,11 +2799,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2795,11 +2821,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2818,11 +2843,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2841,7 +2865,7 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -2863,11 +2887,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2886,11 +2909,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2909,11 +2931,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2932,11 +2953,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2955,11 +2975,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2974,11 +2993,11 @@ JsonSerializerOptions options return new(element); } - case "minimum": + case "minimum_composite": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -2996,14 +3015,11 @@ JsonSerializerOptions options return new(element); } - case "minimum_composite": + case "percent": { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3018,37 +3034,11 @@ JsonSerializerOptions options return new(element); } - case "percent": + 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); - } - case "event_output": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -3065,14 +3055,14 @@ JsonSerializerOptions options } default: { - return new PricePrice(element); + return new LicenseAllocationPrice(element); } } } public override void Write( Utf8JsonWriter writer, - PricePrice? value, + LicenseAllocationPrice? value, JsonSerializerOptions options ) { @@ -3080,55 +3070,56 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.BulkWithFilters, - global::Orb.Models.Plans.BulkWithFiltersFromRaw - >) -)] -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 global::Orb.Models.Plans.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); } } /// @@ -3157,6 +3148,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. /// @@ -3216,14 +3220,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); } } @@ -3312,6 +3314,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 @@ -3350,19 +3365,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(); @@ -3374,138 +3388,179 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public BulkWithFilters() + public Unit() { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("unit"); } - public BulkWithFilters(global::Orb.Models.Plans.BulkWithFilters bulkWithFilters) - : base(bulkWithFilters) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Plans.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Unit FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class BulkWithFiltersFromRaw : IFromRawJson +class UnitFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.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< - global::Orb.Models.Plans.BulkWithFiltersConfig, - global::Orb.Models.Plans.BulkWithFiltersConfigFromRaw - >) -)] -public sealed record class BulkWithFiltersConfig : JsonModel +[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 { /// - /// Property filters to apply (all must match) + /// The amount of credits granted per active license per cadence. /// - public required IReadOnlyList Filters + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>( - "filters" - ); - } - init - { - this._rawData.Set>( - "filters", - ImmutableArray.ToImmutableArray(value) - ); + return this._rawData.GetNotNullClass("amount"); } + init { this._rawData.Set("amount", value); } } /// - /// Bulk tiers for rating based on total usage volume + /// The currency of the license allocation. /// - public required IReadOnlyList Tiers + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>( - "tiers" - ); + return this._rawData.GetNotNullClass("currency"); } - init + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get { - this._rawData.Set>( - "tiers", - ImmutableArray.ToImmutableArray(value) - ); + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) - { - item.Validate(); - } + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public BulkWithFiltersConfig() { } + public LicenseAllocation() { } - public BulkWithFiltersConfig( - global::Orb.Models.Plans.BulkWithFiltersConfig bulkWithFiltersConfig - ) - : base(bulkWithFiltersConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseAllocation(LicenseAllocation licenseAllocation) + : base(licenseAllocation) { } +#pragma warning restore CS8618 - public BulkWithFiltersConfig(IReadOnlyDictionary rawData) + public LicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - BulkWithFiltersConfig(FrozenDictionary rawData) + LicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.BulkWithFiltersConfig FromRawUnchecked( + /// + public static LicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -3513,289 +3568,67 @@ IReadOnlyDictionary rawData } } -class BulkWithFiltersConfigFromRaw : IFromRawJson +class LicenseAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.BulkWithFiltersConfig.FromRawUnchecked(rawData); + public LicenseAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => + LicenseAllocation.FromRawUnchecked(rawData); } -/// -/// Configuration for a single property filter -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.Filter, - global::Orb.Models.Plans.FilterFromRaw - >) -)] -public sealed record class Filter : JsonModel +[JsonConverter(typeof(ConversionRateConfigConverter))] +public record class ConversionRateConfig : ModelBase { - /// - /// Event property key to filter on - /// - public required string PropertyKey + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_key"); + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); } - init { this._rawData.Set("property_key", value); } } - /// - /// Event property value to match - /// - public required string PropertyValue + public ConversionRateConfig(SharedUnitConversionRateConfig value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); - } - init { this._rawData.Set("property_value", value); } + this.Value = value; + this._element = element; } - /// - public override void Validate() + public ConversionRateConfig(SharedTieredConversionRateConfig value, JsonElement? element = null) { - _ = this.PropertyKey; - _ = this.PropertyValue; + this.Value = value; + this._element = element; } - public Filter() { } - - public Filter(global::Orb.Models.Plans.Filter filter) - : base(filter) { } - - public Filter(IReadOnlyDictionary rawData) + public ConversionRateConfig(JsonElement element) { - this._rawData = new(rawData); + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - Filter(FrozenDictionary 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.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Plans.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class FilterFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Plans.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.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() { } - - public Tier(global::Orb.Models.Plans.Tier tier) - : base(tier) { } - - 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 global::Orb.Models.Plans.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public Tier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } -} - -class TierFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Plans.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Tier.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(global::Orb.Models.Plans.CadenceConverter))] -public enum Cadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class CadenceConverter : JsonConverter -{ - public override global::Orb.Models.Plans.Cadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - 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), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Plans.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", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -[JsonConverter(typeof(global::Orb.Models.Plans.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; + value = this.Value as SharedUnitConversionRateConfig; + return value != null; } /// @@ -3895,13 +3728,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,47 +3755,31464 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Plans.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() + { + 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 + { + 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(PricePriceConverter))] +public record class PricePrice : 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 PricePrice(NewPlanUnitPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanTieredPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanBulkPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(PricePriceBulkWithFilters value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanMatrixPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanGroupedTieredPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanTieredPackageWithMinimumPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanUnitWithPercentPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(PricePriceTieredWithProration value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanUnitWithProrationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanGroupedAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanBulkWithProrationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanGroupedWithProratedMinimumPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanGroupedWithMeteredMinimumPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(PricePriceGroupedWithMinMaxThresholds value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanScalableMatrixWithUnitPricingPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice( + NewPlanScalableMatrixWithTieredPricingPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(PricePriceCumulativeGroupedAllocation value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(PricePricePercent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(PricePriceEventOutput value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } + + public PricePrice(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 `PricePriceBulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters([NotNullWhen(true)] out PricePriceBulkWithFilters? value) + { + value = this.Value as PricePriceBulkWithFilters; + return value != null; + } + + /// + /// Returns true and sets the 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 `PricePriceTieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration( + [NotNullWhen(true)] out PricePriceTieredWithProration? value + ) + { + value = this.Value as PricePriceTieredWithProration; + return value != null; + } + + /// + /// Returns true and sets the 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 `PricePriceGroupedWithMinMaxThresholds` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out PricePriceGroupedWithMinMaxThresholds? value + ) + { + value = this.Value as PricePriceGroupedWithMinMaxThresholds; + return value != null; + } + + /// + /// Returns true and sets the 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 `PricePriceCumulativeGroupedAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] out PricePriceCumulativeGroupedAllocation? value + ) + { + value = this.Value as PricePriceCumulativeGroupedAllocation; + return value != null; + } + + /// + /// Returns true and sets the 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 `PricePricePercent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPercent([NotNullWhen(true)] out PricePricePercent? value) + { + 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 . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickEventOutput(out var value)) { + /// // `value` is of type `PricePriceEventOutput` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickEventOutput([NotNullWhen(true)] out PricePriceEventOutput? value) + { + value = this.Value as PricePriceEventOutput; + 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) => {...}, + /// (PricePriceBulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (PricePriceTieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (PricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (PricePriceCumulativeGroupedAllocation value) => {...}, + /// (NewPlanMinimumCompositePrice value) => {...}, + /// (PricePricePercent value) => {...}, + /// (PricePriceEventOutput 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 PricePriceBulkWithFilters 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 PricePriceTieredWithProration 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 PricePriceGroupedWithMinMaxThresholds 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 PricePriceCumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case NewPlanMinimumCompositePrice value: + newPlanMinimumComposite(value); + break; + case PricePricePercent value: + percent(value); + break; + case PricePriceEventOutput value: + eventOutput(value); + break; + default: + throw new OrbInvalidDataException("Data did not match any variant of PricePrice"); + } + } + + /// + /// 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) => {...}, + /// (PricePriceBulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (PricePriceTieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (PricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (PricePriceCumulativeGroupedAllocation value) => {...}, + /// (NewPlanMinimumCompositePrice value) => {...}, + /// (PricePricePercent value) => {...}, + /// (PricePriceEventOutput 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), + PricePriceBulkWithFilters 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), + PricePriceTieredWithProration value => tieredWithProration(value), + NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), + NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), + NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), + NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( + value + ), + NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), + PricePriceGroupedWithMinMaxThresholds 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), + PricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), + NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), + PricePricePercent value => percent(value), + PricePriceEventOutput value => eventOutput(value), + _ => throw new OrbInvalidDataException("Data did not match any variant of PricePrice"), + }; + } + + public static implicit operator PricePrice(NewPlanUnitPrice value) => new(value); + + public static implicit operator PricePrice(NewPlanTieredPrice value) => new(value); + + public static implicit operator PricePrice(NewPlanBulkPrice value) => new(value); + + public static implicit operator PricePrice(PricePriceBulkWithFilters value) => new(value); + + public static implicit operator PricePrice(NewPlanPackagePrice value) => new(value); + + public static implicit operator PricePrice(NewPlanMatrixPrice value) => new(value); + + public static implicit operator PricePrice(NewPlanThresholdTotalAmountPrice value) => + new(value); + + public static implicit operator PricePrice(NewPlanTieredPackagePrice value) => new(value); + + public static implicit operator PricePrice(NewPlanTieredWithMinimumPrice value) => new(value); + + public static implicit operator PricePrice(NewPlanGroupedTieredPrice value) => new(value); + + public static implicit operator PricePrice(NewPlanTieredPackageWithMinimumPrice value) => + new(value); + + public static implicit operator PricePrice(NewPlanPackageWithAllocationPrice value) => + new(value); + + public static implicit operator PricePrice(NewPlanUnitWithPercentPrice value) => new(value); + + public static implicit operator PricePrice(NewPlanMatrixWithAllocationPrice value) => + new(value); + + public static implicit operator PricePrice(PricePriceTieredWithProration value) => new(value); + + public static implicit operator PricePrice(NewPlanUnitWithProrationPrice value) => new(value); + + public static implicit operator PricePrice(NewPlanGroupedAllocationPrice value) => new(value); + + public static implicit operator PricePrice(NewPlanBulkWithProrationPrice value) => new(value); + + public static implicit operator PricePrice(NewPlanGroupedWithProratedMinimumPrice value) => + new(value); + + public static implicit operator PricePrice(NewPlanGroupedWithMeteredMinimumPrice value) => + new(value); + + public static implicit operator PricePrice(PricePriceGroupedWithMinMaxThresholds value) => + new(value); + + public static implicit operator PricePrice(NewPlanMatrixWithDisplayNamePrice value) => + new(value); + + public static implicit operator PricePrice(NewPlanGroupedTieredPackagePrice value) => + new(value); + + public static implicit operator PricePrice(NewPlanMaxGroupTieredPackagePrice value) => + new(value); + + public static implicit operator PricePrice(NewPlanScalableMatrixWithUnitPricingPrice value) => + new(value); + + public static implicit operator PricePrice(NewPlanScalableMatrixWithTieredPricingPrice value) => + new(value); + + public static implicit operator PricePrice(NewPlanCumulativeGroupedBulkPrice 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(PricePricePercent 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 + /// (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 PricePrice"); + } + 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(PricePrice? 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, + PricePriceBulkWithFilters _ => 3, + NewPlanPackagePrice _ => 4, + NewPlanMatrixPrice _ => 5, + NewPlanThresholdTotalAmountPrice _ => 6, + NewPlanTieredPackagePrice _ => 7, + NewPlanTieredWithMinimumPrice _ => 8, + NewPlanGroupedTieredPrice _ => 9, + NewPlanTieredPackageWithMinimumPrice _ => 10, + NewPlanPackageWithAllocationPrice _ => 11, + NewPlanUnitWithPercentPrice _ => 12, + NewPlanMatrixWithAllocationPrice _ => 13, + PricePriceTieredWithProration _ => 14, + NewPlanUnitWithProrationPrice _ => 15, + NewPlanGroupedAllocationPrice _ => 16, + NewPlanBulkWithProrationPrice _ => 17, + NewPlanGroupedWithProratedMinimumPrice _ => 18, + NewPlanGroupedWithMeteredMinimumPrice _ => 19, + PricePriceGroupedWithMinMaxThresholds _ => 20, + NewPlanMatrixWithDisplayNamePrice _ => 21, + NewPlanGroupedTieredPackagePrice _ => 22, + NewPlanMaxGroupTieredPackagePrice _ => 23, + NewPlanScalableMatrixWithUnitPricingPrice _ => 24, + NewPlanScalableMatrixWithTieredPricingPrice _ => 25, + NewPlanCumulativeGroupedBulkPrice _ => 26, + PricePriceCumulativeGroupedAllocation _ => 27, + NewPlanMinimumCompositePrice _ => 28, + PricePricePercent _ => 29, + PricePriceEventOutput _ => 30, + _ => -1, + }; + } +} + +sealed class PricePriceConverter : JsonConverter +{ + public override PricePrice? 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 + } - public override int GetHashCode() - { - return 0; - } + return new(element); + } + case "scalable_matrix_with_tiered_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + return new(element); + } + case "cumulative_grouped_bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -sealed class ConversionRateConfigConverter - : JsonConverter -{ - public override global::Orb.Models.Plans.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; - } + 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 + } - switch (conversionRateType) - { - case "unit": + return new(element); + } + case "minimum_composite": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -3982,11 +35230,33 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "percent": { 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 "event_output": + { + try + { + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -4006,40 +35276,52 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.ConversionRateConfig(element); + return new PricePrice(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.ConversionRateConfig value, + PricePrice? value, JsonSerializerOptions options ) { - JsonSerializer.Serialize(writer, value.Json, options); + JsonSerializer.Serialize(writer, value?.Json, options); } } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.TieredWithProration, - global::Orb.Models.Plans.TieredWithProrationFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class TieredWithProration : JsonModel +public sealed record class PricePriceBulkWithFilters : JsonModel { + /// + /// Configuration for bulk_with_filters pricing + /// + public required PricePriceBulkWithFiltersBulkWithFiltersConfig 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 - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } @@ -4083,21 +35365,6 @@ public required string Name init { this._rawData.Set("name", value); } } - /// - /// Configuration for tiered_with_proration pricing - /// - public required global::Orb.Models.Plans.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. /// @@ -4157,12 +35424,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 PricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4253,6 +35520,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 @@ -4291,19 +35571,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(); @@ -4315,35 +35595,147 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public TieredWithProration() + public PricePriceBulkWithFilters() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePriceBulkWithFilters(PricePriceBulkWithFilters pricePriceBulkWithFilters) + : base(pricePriceBulkWithFilters) { } +#pragma warning restore CS8618 + + public PricePriceBulkWithFilters(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PricePriceBulkWithFilters(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PricePriceBulkWithFiltersFromRaw : IFromRawJson +{ + /// + public PricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PricePriceBulkWithFilters.FromRawUnchecked(rawData); +} + +/// +/// Configuration for bulk_with_filters pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + PricePriceBulkWithFiltersBulkWithFiltersConfig, + PricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) +)] +public sealed record class PricePriceBulkWithFiltersBulkWithFiltersConfig : 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() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + foreach (var item in this.Filters) + { + item.Validate(); + } + foreach (var item in this.Tiers) + { + item.Validate(); + } } - public TieredWithProration(global::Orb.Models.Plans.TieredWithProration tieredWithProration) - : base(tieredWithProration) { } + public PricePriceBulkWithFiltersBulkWithFiltersConfig() { } - public TieredWithProration(IReadOnlyDictionary rawData) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePriceBulkWithFiltersBulkWithFiltersConfig( + PricePriceBulkWithFiltersBulkWithFiltersConfig pricePriceBulkWithFiltersBulkWithFiltersConfig + ) + : base(pricePriceBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 + + public PricePriceBulkWithFiltersBulkWithFiltersConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProration(FrozenDictionary rawData) + PricePriceBulkWithFiltersBulkWithFiltersConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.TieredWithProration FromRawUnchecked( + /// + public static PricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4351,246 +35743,262 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationFromRaw : IFromRawJson +class PricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + : IFromRawJson { /// - public global::Orb.Models.Plans.TieredWithProration FromRawUnchecked( + public PricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.TieredWithProration.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(global::Orb.Models.Plans.TieredWithProrationCadenceConverter))] -public enum TieredWithProrationCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class TieredWithProrationCadenceConverter - : JsonConverter -{ - public override global::Orb.Models.Plans.TieredWithProrationCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - 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), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Plans.TieredWithProrationCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - 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", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } + ) => PricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); } /// -/// Configuration for tiered_with_proration pricing +/// Configuration for a single property filter /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Plans.TieredWithProrationConfig, - global::Orb.Models.Plans.TieredWithProrationConfigFromRaw + PricePriceBulkWithFiltersBulkWithFiltersConfigFilter, + PricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw >) )] -public sealed record class TieredWithProrationConfig : JsonModel +public sealed record class PricePriceBulkWithFiltersBulkWithFiltersConfigFilter : 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 TieredWithProrationConfig() { } + public PricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } - public TieredWithProrationConfig( - global::Orb.Models.Plans.TieredWithProrationConfig tieredWithProrationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + PricePriceBulkWithFiltersBulkWithFiltersConfigFilter pricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) - : base(tieredWithProrationConfig) { } + : base(pricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 - public TieredWithProrationConfig(IReadOnlyDictionary rawData) + public PricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationConfig(FrozenDictionary rawData) + PricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.TieredWithProrationConfig FromRawUnchecked( + /// + public static PricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public TieredWithProrationConfig( - IReadOnlyList tiers - ) - : this() - { - this.Tiers = tiers; - } } -class TieredWithProrationConfigFromRaw - : IFromRawJson +class PricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson { /// - public global::Orb.Models.Plans.TieredWithProrationConfig FromRawUnchecked( + public PricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.TieredWithProrationConfig.FromRawUnchecked(rawData); + ) => PricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); } /// -/// Configuration for a single tiered with proration tier +/// Configuration for a single bulk pricing tier /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Plans.TieredWithProrationConfigTier, - global::Orb.Models.Plans.TieredWithProrationConfigTierFromRaw + PricePriceBulkWithFiltersBulkWithFiltersConfigTier, + PricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw >) )] -public sealed record class TieredWithProrationConfigTier : JsonModel +public sealed record class PricePriceBulkWithFiltersBulkWithFiltersConfigTier : 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 TieredWithProrationConfigTier() { } + public PricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } - public TieredWithProrationConfigTier( - global::Orb.Models.Plans.TieredWithProrationConfigTier tieredWithProrationConfigTier +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePriceBulkWithFiltersBulkWithFiltersConfigTier( + PricePriceBulkWithFiltersBulkWithFiltersConfigTier pricePriceBulkWithFiltersBulkWithFiltersConfigTier ) - : base(tieredWithProrationConfigTier) { } + : base(pricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 - public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) + public PricePriceBulkWithFiltersBulkWithFiltersConfigTier( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationConfigTier(FrozenDictionary rawData) + PricePriceBulkWithFiltersBulkWithFiltersConfigTier( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.TieredWithProrationConfigTier FromRawUnchecked( + /// + public static PricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public PricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } } -class TieredWithProrationConfigTierFromRaw - : IFromRawJson +class PricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson { /// - public global::Orb.Models.Plans.TieredWithProrationConfigTier FromRawUnchecked( + public PricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.TieredWithProrationConfigTier.FromRawUnchecked(rawData); + ) => PricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Plans.TieredWithProrationConversionRateConfigConverter))] -public record class TieredWithProrationConversionRateConfig : ModelBase +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PricePriceBulkWithFiltersCadenceConverter))] +public enum PricePriceBulkWithFiltersCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PricePriceBulkWithFiltersCadenceConverter + : JsonConverter +{ + public override PricePriceBulkWithFiltersCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + PricePriceBulkWithFiltersCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(PricePriceBulkWithFiltersConversionRateConfigConverter))] +public record class PricePriceBulkWithFiltersConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4607,7 +36015,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public PricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -4616,7 +36024,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public PricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -4625,7 +36033,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public PricePriceBulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -4707,7 +36115,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of PricePriceBulkWithFiltersConversionRateConfig" ); } } @@ -4743,16 +36151,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 PricePriceBulkWithFiltersConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Plans.TieredWithProrationConversionRateConfig( + public static implicit operator PricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Plans.TieredWithProrationConversionRateConfig( + public static implicit operator PricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -4771,18 +36179,16 @@ 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 PricePriceBulkWithFiltersConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Plans.TieredWithProrationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PricePriceBulkWithFiltersConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4790,13 +36196,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class TieredWithProrationConversionRateConfigConverter - : JsonConverter +sealed class PricePriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Plans.TieredWithProrationConversionRateConfig? Read( + public override PricePriceBulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4861,16 +36280,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.TieredWithProrationConversionRateConfig( - element - ); + return new PricePriceBulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.TieredWithProrationConversionRateConfig value, + PricePriceBulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -4879,46 +36296,25 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.GroupedWithMinMaxThresholds, - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class GroupedWithMinMaxThresholds : JsonModel +public sealed record class PricePriceTieredWithProration : 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); } } - /// - /// Configuration for grouped_with_min_max_thresholds pricing - /// - public required global::Orb.Models.Plans.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. /// @@ -4958,6 +36354,21 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for tiered_with_proration pricing + /// + public required PricePriceTieredWithProrationTieredWithProrationConfig 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. /// @@ -5017,12 +36428,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 PricePriceTieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5113,6 +36524,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 @@ -5152,18 +36576,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(); @@ -5175,37 +36599,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public GroupedWithMinMaxThresholds() + public PricePriceTieredWithProration() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Plans.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePriceTieredWithProration( + PricePriceTieredWithProration pricePriceTieredWithProration ) - : base(groupedWithMinMaxThresholds) { } + : base(pricePriceTieredWithProration) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + public PricePriceTieredWithProration(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] - GroupedWithMinMaxThresholds(FrozenDictionary rawData) + PricePriceTieredWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.GroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static PricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5213,20 +36641,19 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class PricePriceTieredWithProrationFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.GroupedWithMinMaxThresholds FromRawUnchecked( + public PricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => PricePriceTieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadenceConverter))] -public enum GroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(PricePriceTieredWithProrationCadenceConverter))] +public enum PricePriceTieredWithProrationCadence { Annual, SemiAnnual, @@ -5236,10 +36663,10 @@ public enum GroupedWithMinMaxThresholdsCadence Custom, } -sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class PricePriceTieredWithProrationCadenceConverter + : JsonConverter { - public override global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence Read( + public override PricePriceTieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5247,19 +36674,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" => 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, - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsCadence value, + PricePriceTieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -5267,14 +36694,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", + 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)) ), @@ -5285,99 +36710,173 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for tiered_with_proration pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfigFromRaw + PricePriceTieredWithProrationTieredWithProrationConfig, + PricePriceTieredWithProrationTieredWithProrationConfigFromRaw >) )] -public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel +public sealed record class PricePriceTieredWithProrationTieredWithProrationConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration /// - public required string GroupingKey + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); } - init { this._rawData.Set("grouping_key", value); } } - /// - /// The maximum amount to charge each group - /// - public required string MaximumCharge + /// + public override void Validate() { - get + foreach (var item in this.Tiers) { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + item.Validate(); } - init { this._rawData.Set("maximum_charge", value); } } + public PricePriceTieredWithProrationTieredWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePriceTieredWithProrationTieredWithProrationConfig( + PricePriceTieredWithProrationTieredWithProrationConfig pricePriceTieredWithProrationTieredWithProrationConfig + ) + : base(pricePriceTieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 + + public PricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PricePriceTieredWithProrationTieredWithProrationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public PricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } +} + +class PricePriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public PricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tiered with proration tier +/// +[JsonConverter( + typeof(JsonModelConverter< + PricePriceTieredWithProrationTieredWithProrationConfigTier, + PricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + >) +)] +public sealed record class PricePriceTieredWithProrationTieredWithProrationConfigTier : JsonModel +{ /// - /// The minimum amount to charge each group, regardless of usage + /// Inclusive tier starting value /// - public required string MinimumCharge + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// - /// The base price charged per group + /// Amount per unit /// - public required string PerUnitRate + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("per_unit_rate", value); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.TierLowerBound; + _ = this.UnitAmount; } - public GroupedWithMinMaxThresholdsConfig() { } + public PricePriceTieredWithProrationTieredWithProrationConfigTier() { } - public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePriceTieredWithProrationTieredWithProrationConfigTier( + PricePriceTieredWithProrationTieredWithProrationConfigTier pricePriceTieredWithProrationTieredWithProrationConfigTier ) - : base(groupedWithMinMaxThresholdsConfig) { } + : base(pricePriceTieredWithProrationTieredWithProrationConfigTier) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) + public PricePriceTieredWithProrationTieredWithProrationConfigTier( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) + PricePriceTieredWithProrationTieredWithProrationConfigTier( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static PricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5385,19 +36884,17 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class PricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson { /// - public global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public PricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); + ) => PricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] -public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(PricePriceTieredWithProrationConversionRateConfigConverter))] +public record class PricePriceTieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5414,7 +36911,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public PricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5423,7 +36920,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public PricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5432,7 +36929,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public PricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -5514,7 +37011,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of PricePriceTieredWithProrationConversionRateConfig" ); } } @@ -5550,16 +37047,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 PricePriceTieredWithProrationConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator PricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator PricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5578,18 +37075,16 @@ 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 PricePriceTieredWithProrationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PricePriceTieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5597,13 +37092,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class PricePriceTieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override PricePriceTieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5668,16 +37176,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new PricePriceTieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.GroupedWithMinMaxThresholdsConversionRateConfig value, + PricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -5687,43 +37193,40 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Plans.CumulativeGroupedAllocation, - global::Orb.Models.Plans.CumulativeGroupedAllocationFromRaw + PricePriceGroupedWithMinMaxThresholds, + PricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class CumulativeGroupedAllocation : JsonModel +public sealed record class PricePriceGroupedWithMinMaxThresholds : 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); } } /// - /// Configuration for cumulative_grouped_allocation pricing + /// Configuration for grouped_with_min_max_thresholds pricing /// - public required global::Orb.Models.Plans.CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig 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); } } /// @@ -5824,12 +37327,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 PricePriceGroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5920,6 +37423,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 @@ -5959,12 +37475,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") ) ) { @@ -5982,37 +37498,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public CumulativeGroupedAllocation() + public PricePriceGroupedWithMinMaxThresholds() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Plans.CumulativeGroupedAllocation cumulativeGroupedAllocation +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePriceGroupedWithMinMaxThresholds( + PricePriceGroupedWithMinMaxThresholds pricePriceGroupedWithMinMaxThresholds ) - : base(cumulativeGroupedAllocation) { } + : base(pricePriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + public PricePriceGroupedWithMinMaxThresholds(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] - CumulativeGroupedAllocation(FrozenDictionary rawData) + PricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.CumulativeGroupedAllocation FromRawUnchecked( + /// + public static PricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6020,20 +37540,20 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class PricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public global::Orb.Models.Plans.CumulativeGroupedAllocation FromRawUnchecked( + public PricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.CumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => PricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Plans.CumulativeGroupedAllocationCadenceConverter))] -public enum CumulativeGroupedAllocationCadence +[JsonConverter(typeof(PricePriceGroupedWithMinMaxThresholdsCadenceConverter))] +public enum PricePriceGroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -6043,10 +37563,10 @@ public enum CumulativeGroupedAllocationCadence Custom, } -sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class PricePriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override global::Orb.Models.Plans.CumulativeGroupedAllocationCadence Read( + public override PricePriceGroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6054,19 +37574,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" => 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, - global::Orb.Models.Plans.CumulativeGroupedAllocationCadence value, + PricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -6074,14 +37594,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", + 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)) ), @@ -6092,99 +37610,107 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for grouped_with_min_max_thresholds pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Plans.CumulativeGroupedAllocationConfig, - global::Orb.Models.Plans.CumulativeGroupedAllocationConfigFromRaw + PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, + PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw >) )] -public sealed record class CumulativeGroupedAllocationConfig : JsonModel +public sealed record class PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + : 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 CumulativeGroupedAllocationConfig() { } + public PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } - public CumulativeGroupedAllocationConfig( - global::Orb.Models.Plans.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig pricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) - : base(cumulativeGroupedAllocationConfig) { } + : base(pricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + public PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6192,19 +37718,20 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson { /// - public global::Orb.Models.Plans.CumulativeGroupedAllocationConfig FromRawUnchecked( + public PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); + ) => + PricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + rawData + ); } -[JsonConverter( - typeof(global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfigConverter) -)] -public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(PricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class PricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6221,7 +37748,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public PricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6230,7 +37757,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public PricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6239,7 +37766,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public PricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -6321,7 +37848,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of PricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -6357,16 +37884,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 PricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator PricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator PricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6385,32 +37912,43 @@ 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 PricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } - - public virtual bool Equals( - global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } + public virtual bool Equals(PricePriceGroupedWithMinMaxThresholdsConversionRateConfig? 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(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class CumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class PricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig? Read( + public override PricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6475,16 +38013,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig( - element - ); + return new PricePriceGroupedWithMinMaxThresholdsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.CumulativeGroupedAllocationConversionRateConfig value, + PricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -6494,51 +38030,53 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Plans.Minimum, - global::Orb.Models.Plans.MinimumFromRaw + PricePriceCumulativeGroupedAllocation, + PricePriceCumulativeGroupedAllocationFromRaw >) )] -public sealed record class Minimum : 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>("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 PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } } /// - /// Configuration for minimum pricing + /// The id of the item the price will be associated with. /// - public required global::Orb.Models.Plans.MinimumConfig 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); } } /// @@ -6626,12 +38164,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public MinimumConversionRateConfig? ConversionRateConfig + public PricePriceCumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6722,6 +38260,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 @@ -6761,9 +38312,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"); } @@ -6779,35 +38335,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Minimum() + public PricePriceCumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public Minimum(global::Orb.Models.Plans.Minimum minimum) - : base(minimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePriceCumulativeGroupedAllocation( + PricePriceCumulativeGroupedAllocation pricePriceCumulativeGroupedAllocation + ) + : base(pricePriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public Minimum(IReadOnlyDictionary rawData) + public PricePriceCumulativeGroupedAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + PricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.Minimum FromRawUnchecked( + /// + public static PricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6815,19 +38377,20 @@ IReadOnlyDictionary rawData } } -class MinimumFromRaw : IFromRawJson +class PricePriceCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public global::Orb.Models.Plans.Minimum FromRawUnchecked( + public PricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Minimum.FromRawUnchecked(rawData); + ) => PricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(MinimumCadenceConverter))] -public enum MinimumCadence +[JsonConverter(typeof(PricePriceCumulativeGroupedAllocationCadenceConverter))] +public enum PricePriceCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -6837,9 +38400,10 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter : JsonConverter +sealed class PricePriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override MinimumCadence Read( + public override PricePriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6847,19 +38411,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" => 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, - MinimumCadence value, + PricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -6867,12 +38431,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", + 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)) ), @@ -6883,101 +38447,128 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Plans.MinimumConfig, - global::Orb.Models.Plans.MinimumConfigFromRaw + PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig, + PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class MinimumConfig : JsonModel +public sealed record class PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + : 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 PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } - public MinimumConfig(global::Orb.Models.Plans.MinimumConfig minimumConfig) - : base(minimumConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig pricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + ) + : base(pricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 - public MinimumConfig(IReadOnlyDictionary rawData) + public PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.MinimumConfig FromRawUnchecked( + /// + public static PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class MinimumConfigFromRaw : IFromRawJson +class PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public global::Orb.Models.Plans.MinimumConfig FromRawUnchecked( + public PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.MinimumConfig.FromRawUnchecked(rawData); + ) => + PricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + rawData + ); } -[JsonConverter(typeof(MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(PricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] +public record class PricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6994,7 +38585,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public PricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7003,7 +38594,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public PricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7012,7 +38603,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public PricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -7094,7 +38685,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PricePriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -7130,16 +38721,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 PricePriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator MinimumConversionRateConfig( + public static implicit operator PricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator MinimumConversionRateConfig( + public static implicit operator PricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7158,16 +38749,16 @@ 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 PricePriceCumulativeGroupedAllocationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(MinimumConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PricePriceCumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7175,12 +38766,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class MinimumConversionRateConfigConverter : JsonConverter +sealed class PricePriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override MinimumConversionRateConfig? Read( + public override PricePriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7245,14 +38850,14 @@ JsonSerializerOptions options } default: { - return new MinimumConversionRateConfig(element); + return new PricePriceCumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MinimumConversionRateConfig value, + PricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -7260,25 +38865,20 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.Percent, - global::Orb.Models.Plans.PercentFromRaw - >) -)] -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< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } @@ -7325,14 +38925,12 @@ public required string Name /// /// Configuration for percent pricing /// - public required global::Orb.Models.Plans.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); } } @@ -7396,12 +38994,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 PricePricePercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7492,6 +39090,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 @@ -7549,19 +39160,23 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Percent() + public PricePricePercent() { this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Percent(global::Orb.Models.Plans.Percent percent) - : base(percent) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePricePercent(PricePricePercent pricePricePercent) + : base(pricePricePercent) { } +#pragma warning restore CS8618 - public Percent(IReadOnlyDictionary rawData) + public PricePricePercent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -7570,14 +39185,14 @@ 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 global::Orb.Models.Plans.Percent FromRawUnchecked( + /// + public static PricePricePercent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7585,19 +39200,18 @@ IReadOnlyDictionary rawData } } -class PercentFromRaw : IFromRawJson +class PricePricePercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Percent.FromRawUnchecked(rawData); + public PricePricePercent FromRawUnchecked(IReadOnlyDictionary rawData) => + PricePricePercent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Plans.PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(PricePricePercentCadenceConverter))] +public enum PricePricePercentCadence { Annual, SemiAnnual, @@ -7607,9 +39221,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter : JsonConverter +sealed class PricePricePercentCadenceConverter : JsonConverter { - public override global::Orb.Models.Plans.PercentCadence Read( + public override PricePricePercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7617,19 +39231,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" => 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, - global::Orb.Models.Plans.PercentCadence value, + PricePricePercentCadence value, JsonSerializerOptions options ) { @@ -7637,12 +39251,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", + 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)) ), @@ -7657,11 +39271,11 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Plans.PercentConfig, - global::Orb.Models.Plans.PercentConfigFromRaw + PricePricePercentPercentConfig, + PricePricePercentPercentConfigFromRaw >) )] -public sealed record class PercentConfig : JsonModel +public sealed record class PricePricePercentPercentConfig : JsonModel { /// /// What percent of the component subtotals to charge @@ -7682,26 +39296,31 @@ public override void Validate() _ = this.Percent; } - public PercentConfig() { } + public PricePricePercentPercentConfig() { } - public PercentConfig(global::Orb.Models.Plans.PercentConfig percentConfig) - : base(percentConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Plans.PercentConfig FromRawUnchecked( + /// + public static PricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7709,23 +39328,23 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public PercentConfig(double percent) + public PricePricePercentPercentConfig(double percent) : this() { this.Percent = percent; } } -class PercentConfigFromRaw : IFromRawJson +class PricePricePercentPercentConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.PercentConfig FromRawUnchecked( + public PricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.PercentConfig.FromRawUnchecked(rawData); + ) => PricePricePercentPercentConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Plans.PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +[JsonConverter(typeof(PricePricePercentConversionRateConfigConverter))] +public record class PricePricePercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7742,7 +39361,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public PricePricePercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7751,7 +39370,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public PricePricePercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7760,7 +39379,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public PricePricePercentConversionRateConfig(JsonElement element) { this._element = element; } @@ -7842,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" ); } } @@ -7878,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 global::Orb.Models.Plans.PercentConversionRateConfig( + public static implicit operator PricePricePercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Plans.PercentConversionRateConfig( + public static implicit operator PricePricePercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7906,16 +39525,16 @@ 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(global::Orb.Models.Plans.PercentConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PricePricePercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7923,13 +39542,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class PercentConversionRateConfigConverter - : JsonConverter +sealed class PricePricePercentConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Plans.PercentConversionRateConfig? Read( + public override PricePricePercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7994,14 +39626,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.PercentConversionRateConfig(element); + return new PricePricePercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.PercentConversionRateConfig value, + PricePricePercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -8009,25 +39641,20 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Plans.EventOutput, - global::Orb.Models.Plans.EventOutputFromRaw - >) -)] -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< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } @@ -8035,12 +39662,12 @@ public sealed record class EventOutput : JsonModel /// /// Configuration for event_output pricing /// - public required global::Orb.Models.Plans.EventOutputConfig EventOutputConfig + public required PricePriceEventOutputEventOutputConfig EventOutputConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "event_output_config" ); } @@ -8145,12 +39772,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 PricePriceEventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8241,6 +39868,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 @@ -8303,19 +39943,23 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public EventOutput() + public PricePriceEventOutput() { this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public EventOutput(global::Orb.Models.Plans.EventOutput eventOutput) - : base(eventOutput) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PricePriceEventOutput(PricePriceEventOutput pricePriceEventOutput) + : base(pricePriceEventOutput) { } +#pragma warning restore CS8618 - public EventOutput(IReadOnlyDictionary rawData) + public PricePriceEventOutput(IReadOnlyDictionary rawData) { this._rawData = new(rawData); @@ -8324,14 +39968,14 @@ 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 global::Orb.Models.Plans.EventOutput FromRawUnchecked( + /// + public static PricePriceEventOutput FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8339,19 +39983,19 @@ IReadOnlyDictionary rawData } } -class EventOutputFromRaw : IFromRawJson +class PricePriceEventOutputFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.EventOutput FromRawUnchecked( + public PricePriceEventOutput FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.EventOutput.FromRawUnchecked(rawData); + ) => PricePriceEventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Plans.EventOutputCadenceConverter))] -public enum EventOutputCadence +[JsonConverter(typeof(PricePriceEventOutputCadenceConverter))] +public enum PricePriceEventOutputCadence { Annual, SemiAnnual, @@ -8361,10 +40005,9 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter - : JsonConverter +sealed class PricePriceEventOutputCadenceConverter : JsonConverter { - public override global::Orb.Models.Plans.EventOutputCadence Read( + public override PricePriceEventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8372,19 +40015,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" => 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, - global::Orb.Models.Plans.EventOutputCadence value, + PricePriceEventOutputCadence value, JsonSerializerOptions options ) { @@ -8392,12 +40035,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", + 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)) ), @@ -8412,11 +40055,11 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Plans.EventOutputConfig, - global::Orb.Models.Plans.EventOutputConfigFromRaw + PricePriceEventOutputEventOutputConfig, + PricePriceEventOutputEventOutputConfigFromRaw >) )] -public sealed record class EventOutputConfig : JsonModel +public sealed record class PricePriceEventOutputEventOutputConfig : JsonModel { /// /// The key in the event data to extract the unit rate from. @@ -8468,26 +40111,31 @@ public override void Validate() _ = this.GroupingKey; } - public EventOutputConfig() { } + public PricePriceEventOutputEventOutputConfig() { } - public EventOutputConfig(global::Orb.Models.Plans.EventOutputConfig eventOutputConfig) - : base(eventOutputConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + 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 global::Orb.Models.Plans.EventOutputConfig FromRawUnchecked( + /// + public static PricePriceEventOutputEventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8495,23 +40143,24 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) + public PricePriceEventOutputEventOutputConfig(string unitRatingKey) : this() { this.UnitRatingKey = unitRatingKey; } } -class EventOutputConfigFromRaw : IFromRawJson +class PricePriceEventOutputEventOutputConfigFromRaw + : IFromRawJson { /// - public global::Orb.Models.Plans.EventOutputConfig FromRawUnchecked( + public PricePriceEventOutputEventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.EventOutputConfig.FromRawUnchecked(rawData); + ) => PricePriceEventOutputEventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Plans.EventOutputConversionRateConfigConverter))] -public record class EventOutputConversionRateConfig : ModelBase +[JsonConverter(typeof(PricePriceEventOutputConversionRateConfigConverter))] +public record class PricePriceEventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8528,7 +40177,7 @@ public JsonElement Json } } - public EventOutputConversionRateConfig( + public PricePriceEventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8537,7 +40186,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig( + public PricePriceEventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8546,7 +40195,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig(JsonElement element) + public PricePriceEventOutputConversionRateConfig(JsonElement element) { this._element = element; } @@ -8628,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" ); } } @@ -8664,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 global::Orb.Models.Plans.EventOutputConversionRateConfig( + public static implicit operator PricePriceEventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Plans.EventOutputConversionRateConfig( + public static implicit operator PricePriceEventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8692,16 +40341,16 @@ 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(global::Orb.Models.Plans.EventOutputConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PricePriceEventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8709,13 +40358,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class EventOutputConversionRateConfigConverter - : JsonConverter +sealed class PricePriceEventOutputConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Plans.EventOutputConversionRateConfig? Read( + public override PricePriceEventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8780,14 +40442,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Plans.EventOutputConversionRateConfig(element); + return new PricePriceEventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Plans.EventOutputConversionRateConfig value, + PricePriceEventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -8795,7 +40457,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Adjustment : JsonModel { /// @@ -8833,8 +40495,11 @@ public override void Validate() public Adjustment() { } - public Adjustment(global::Orb.Models.Plans.Adjustment adjustment) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Adjustment(Adjustment adjustment) : base(adjustment) { } +#pragma warning restore CS8618 public Adjustment(IReadOnlyDictionary rawData) { @@ -8850,9 +40515,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 +40528,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); } /// @@ -9199,10 +40861,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() { @@ -9210,7 +40872,23 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + 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 AdjustmentAdjustmentConverter : JsonConverter @@ -9398,14 +41076,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); } } @@ -9421,8 +41097,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) { @@ -9458,7 +41137,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 +41147,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 +41157,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 +41176,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 +41194,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 +41211,20 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "active" => global::Orb.Models.Plans.Status.Active, - "draft" => global::Orb.Models.Plans.Status.Draft, - _ => (global::Orb.Models.Plans.Status)(-1), + "active" => Status.Active, + "draft" => Status.Draft, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Plans.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Plans.Status.Active => "active", - global::Orb.Models.Plans.Status.Draft => "draft", + Status.Active => "active", + Status.Draft => "draft", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Plans/PlanFetchParams.cs b/src/Orb/Models/Plans/PlanFetchParams.cs index 9fb892efc..f5c596944 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +119,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/PlanListPage.cs b/src/Orb/Models/Plans/PlanListPage.cs index 89d2daa30..f502c3bc8 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; @@ -62,5 +63,20 @@ 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) + { + 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/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/Plans/PlanListParams.cs b/src/Orb/Models/Plans/PlanListParams.cs index 33edcf175..f0ac3f9a6 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,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(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 +203,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..7938bf877 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +176,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Price.cs b/src/Orb/Models/Price.cs index 9a7e02212..8dad84b83 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,17 +2146,16 @@ 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() ); } - 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() { @@ -2222,7 +2163,49 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + 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 PriceConverter : JsonConverter @@ -2841,25 +2824,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 @@ -3262,6 +3226,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() { @@ -3299,6 +3278,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.UnitConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -3309,11 +3289,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" @@ -3512,8 +3495,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) { @@ -3836,10 +3822,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() { @@ -3847,7 +3833,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class UnitConversionRateConfigConverter : JsonConverter @@ -3979,6 +3978,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 { @@ -4310,6 +4400,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() { @@ -4347,6 +4452,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -4357,11 +4463,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" @@ -4562,8 +4671,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) { @@ -4888,10 +5000,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() { @@ -4899,7 +5011,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class TieredConversionRateConfigConverter : JsonConverter @@ -5031,6 +5156,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 { @@ -5360,6 +5578,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() { @@ -5397,6 +5630,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -5407,11 +5641,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" @@ -5612,8 +5849,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) { @@ -5937,10 +6177,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() { @@ -5948,7 +6188,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class BulkConversionRateConfigConverter : JsonConverter @@ -6080,6 +6333,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 { @@ -6415,6 +6759,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() { @@ -6457,6 +6816,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -6467,11 +6827,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" @@ -6615,8 +6978,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) { @@ -6691,8 +7057,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) { @@ -6767,8 +7136,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) { @@ -6930,10 +7302,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) { @@ -7258,10 +7633,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() { @@ -7269,7 +7644,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class BulkWithFiltersConversionRateConfigConverter @@ -7402,6 +7790,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 { @@ -7733,6 +8217,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() { @@ -7770,6 +8269,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -7780,11 +8280,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" @@ -7985,8 +8488,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) { @@ -8311,10 +8817,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() { @@ -8322,7 +8828,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PackageConversionRateConfigConverter : JsonConverter @@ -8454,6 +8973,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 { @@ -8785,6 +9397,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() { @@ -8822,6 +9449,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -8832,11 +9460,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" @@ -9037,8 +9668,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) { @@ -9363,10 +9997,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() { @@ -9374,7 +10008,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class MatrixConversionRateConfigConverter : JsonConverter @@ -9506,6 +10153,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 { @@ -9843,6 +10583,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() { @@ -9885,6 +10640,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.ThresholdTotalAmountConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -9895,11 +10651,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" @@ -10107,10 +10866,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 @@ -10438,10 +11200,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() { @@ -10449,7 +11211,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ThresholdTotalAmountConversionRateConfigConverter @@ -10639,10 +11414,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 @@ -10730,10 +11508,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 @@ -10770,6 +11551,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 { @@ -11105,6 +11987,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() { @@ -11147,6 +12044,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredPackageConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -11157,11 +12055,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" @@ -11365,10 +12266,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) { @@ -11693,10 +12597,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() { @@ -11704,7 +12608,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class TieredPackageConversionRateConfigConverter @@ -11894,10 +12811,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) { @@ -11972,10 +12892,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) { @@ -12008,6 +12931,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 { @@ -12345,6 +13364,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() { @@ -12387,6 +13421,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredWithMinimumConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -12397,11 +13432,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" @@ -12607,10 +13645,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) { @@ -12936,10 +13977,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() { @@ -12947,7 +13988,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class TieredWithMinimumConversionRateConfigConverter @@ -13168,10 +14222,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 @@ -13269,10 +14326,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 @@ -13307,6 +14367,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 { @@ -13642,6 +14798,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() { @@ -13684,6 +14855,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -13694,11 +14866,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" @@ -13902,10 +15077,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) { @@ -14230,10 +15408,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() { @@ -14241,7 +15419,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedTieredConversionRateConfigConverter @@ -14384,10 +15575,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) { @@ -14462,10 +15656,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) { @@ -14545,6 +15742,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) )] @@ -14884,6 +16177,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() { @@ -14926,6 +16236,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredPackageWithMinimumConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -14936,11 +16247,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" @@ -15149,10 +16463,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 @@ -15481,10 +16798,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() { @@ -15492,7 +16809,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class TieredPackageWithMinimumConversionRateConfigConverter @@ -15680,10 +17010,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 @@ -15771,10 +17104,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 @@ -15811,6 +17147,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 { @@ -16148,6 +17585,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() { @@ -16190,6 +17642,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -16200,11 +17653,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" @@ -16412,10 +17868,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 @@ -16743,10 +18202,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() { @@ -16754,7 +18213,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PackageWithAllocationConversionRateConfigConverter @@ -16891,10 +18363,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 @@ -16976,6 +18451,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 { @@ -17313,6 +18889,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() { @@ -17355,6 +18946,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.UnitWithPercentConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -17365,11 +18957,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" @@ -17573,10 +19168,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) { @@ -17901,10 +19499,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() { @@ -17912,7 +19510,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class UnitWithPercentConversionRateConfigConverter @@ -18091,10 +19702,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) { @@ -18127,6 +19741,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 { @@ -18464,6 +20174,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() { @@ -18506,6 +20231,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -18516,11 +20242,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" @@ -18728,10 +20457,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 @@ -19059,10 +20791,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() { @@ -19070,7 +20802,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class MatrixWithAllocationConversionRateConfigConverter @@ -19203,6 +20948,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 { @@ -19540,6 +21386,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() { @@ -19582,6 +21443,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredWithProrationConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -19592,11 +21454,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" @@ -19802,10 +21667,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) { @@ -20131,10 +21999,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() { @@ -20142,7 +22010,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class TieredWithProrationConversionRateConfigConverter @@ -20319,10 +22200,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 @@ -20412,10 +22296,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 @@ -20450,6 +22337,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 { @@ -20787,6 +22775,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() { @@ -20829,6 +22832,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.UnitWithProrationConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -20839,11 +22843,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" @@ -21049,10 +23056,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) { @@ -21378,10 +23388,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() { @@ -21389,7 +23399,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class UnitWithProrationConversionRateConfigConverter @@ -21554,10 +23577,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 @@ -21599,6 +23625,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 { @@ -21936,6 +24058,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() { @@ -21978,6 +24115,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -21988,11 +24126,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" @@ -22198,10 +24339,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) { @@ -22527,10 +24671,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() { @@ -22538,7 +24682,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedAllocationConversionRateConfigConverter @@ -22684,10 +24841,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 @@ -22769,6 +24929,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 { @@ -23106,6 +25362,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() { @@ -23148,6 +25419,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -23158,11 +25430,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" @@ -23288,10 +25563,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 @@ -23381,10 +25659,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 @@ -23549,10 +25830,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) { @@ -23878,10 +26162,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() { @@ -23889,7 +26173,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class BulkWithProrationConversionRateConfigConverter @@ -24022,6 +26319,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) )] @@ -24361,6 +26754,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() { @@ -24403,6 +26813,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -24413,11 +26824,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" @@ -24626,10 +27040,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 @@ -24958,10 +27375,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() { @@ -24969,7 +27386,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedWithProratedMinimumConversionRateConfigConverter @@ -25115,10 +27545,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 @@ -25203,6 +27636,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) )] @@ -25542,6 +28077,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() { @@ -25584,6 +28136,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -25594,11 +28147,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" @@ -25807,10 +28363,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 @@ -26139,10 +28698,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() { @@ -26150,7 +28709,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedWithMeteredMinimumConversionRateConfigConverter @@ -26360,10 +28932,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 @@ -26441,10 +29016,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 @@ -26528,10 +29106,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 @@ -26619,6 +29200,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) )] @@ -26958,6 +29641,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() { @@ -27000,6 +29700,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -27010,11 +29711,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" @@ -27226,10 +29930,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 @@ -27558,10 +30265,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() { @@ -27569,7 +30276,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -27729,10 +30449,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) { @@ -27812,6 +30535,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 { @@ -28149,6 +30974,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() { @@ -28191,6 +31031,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -28201,11 +31042,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" @@ -28413,10 +31257,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 @@ -28744,10 +31591,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() { @@ -28755,7 +31602,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class MatrixWithDisplayNameConversionRateConfigConverter @@ -28897,10 +31757,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 @@ -28995,10 +31858,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 @@ -29082,6 +31948,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 { @@ -29419,6 +32386,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() { @@ -29461,6 +32443,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -29471,11 +32454,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" @@ -29683,10 +32669,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 @@ -30014,10 +33003,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() { @@ -30025,7 +33014,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedTieredPackageConversionRateConfigConverter @@ -30180,10 +33182,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 @@ -30261,10 +33266,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 @@ -30348,6 +33356,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 { @@ -30685,6 +33794,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() { @@ -30727,6 +33851,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -30737,11 +33862,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" @@ -30949,10 +34077,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 @@ -31280,10 +34411,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() { @@ -31291,7 +34422,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class MaxGroupTieredPackageConversionRateConfigConverter @@ -31445,10 +34589,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 @@ -31526,10 +34673,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 @@ -31613,6 +34763,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) )] @@ -31952,6 +35203,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() { @@ -31994,6 +35262,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.ScalableMatrixWithUnitPricingConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -32004,6 +35273,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" )] @@ -32011,6 +35282,7 @@ public ScalableMatrixWithUnitPricing( ScalableMatrixWithUnitPricing scalableMatrixWithUnitPricing ) : base(scalableMatrixWithUnitPricing) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -32222,10 +35494,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 @@ -32555,10 +35830,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() { @@ -32566,7 +35841,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ScalableMatrixWithUnitPricingConversionRateConfigConverter @@ -32758,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 /// @@ -32793,16 +36094,20 @@ public override void Validate() item.Validate(); } _ = this.UnitPrice; + _ = this.GroupingKey; _ = this.Prorate; _ = this.SecondDimension; } public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig ) : base(scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig) { } +#pragma warning restore CS8618 public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( IReadOnlyDictionary rawData @@ -32891,11 +36196,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 @@ -32935,6 +36243,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, @@ -33277,6 +36689,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() { @@ -33319,6 +36748,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.ScalableMatrixWithTieredPricingConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -33329,6 +36759,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" )] @@ -33336,6 +36768,7 @@ public ScalableMatrixWithTieredPricing( ScalableMatrixWithTieredPricing scalableMatrixWithTieredPricing ) : base(scalableMatrixWithTieredPricing) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -33547,10 +36980,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 @@ -33882,10 +37318,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() { @@ -33893,7 +37329,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ScalableMatrixWithTieredPricingConversionRateConfigConverter @@ -34119,10 +37568,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 @@ -34215,12 +37667,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 @@ -34301,10 +37756,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 @@ -34344,6 +37802,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 { @@ -34681,6 +38243,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() { @@ -34723,6 +38300,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -34733,11 +38311,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" @@ -34945,10 +38526,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 @@ -35206,1282 +38790,7 @@ public void Switch( 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) - { - 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 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); - } -} - -/// -/// Configuration for cumulative_grouped_bulk pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - CumulativeGroupedBulkCumulativeGroupedBulkConfig, - CumulativeGroupedBulkCumulativeGroupedBulkConfigFromRaw - >) -)] -public sealed record class CumulativeGroupedBulkCumulativeGroupedBulkConfig : 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 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 -{ - /// - /// 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 CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue() { } - - public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( - CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue cumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue - ) - : base(cumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue) { } - - public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueFromRaw - : IFromRawJson -{ - /// - public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue FromRawUnchecked( - IReadOnlyDictionary rawData - ) => CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(CumulativeGroupedBulkPriceTypeConverter))] -public enum CumulativeGroupedBulkPriceType -{ - UsagePrice, - FixedPrice, - CompositePrice, -} - -sealed class CumulativeGroupedBulkPriceTypeConverter : JsonConverter -{ - public override CumulativeGroupedBulkPriceType Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "usage_price" => CumulativeGroupedBulkPriceType.UsagePrice, - "fixed_price" => CumulativeGroupedBulkPriceType.FixedPrice, - "composite_price" => CumulativeGroupedBulkPriceType.CompositePrice, - _ => (CumulativeGroupedBulkPriceType)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - CumulativeGroupedBulkPriceType value, - JsonSerializerOptions options - ) - { - 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 - ); - } -} - -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class CumulativeGroupedAllocation : 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 - { - 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 CumulativeGroupedAllocationConversionRateConfig? 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); } - } - - /// - /// 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 - { - 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); } - } - - 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.CumulativeGroupedAllocationConfig.Validate(); - _ = this.Currency; - this.Discount?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - 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("cumulative_grouped_allocation") - ) - ) - { - 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 CumulativeGroupedAllocation() - { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); - } - - [System::Obsolete( - "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" - )] - public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) - : base(cumulativeGroupedAllocation) { } - - [System::Obsolete( - "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" - )] - public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); - } - -#pragma warning disable CS8618 - [System::Obsolete( - "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" - )] - [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); -} - -[JsonConverter(typeof(CumulativeGroupedAllocationBillingModeConverter))] -public enum CumulativeGroupedAllocationBillingMode -{ - InAdvance, - InArrear, -} - -sealed class CumulativeGroupedAllocationBillingModeConverter - : JsonConverter -{ - public override CumulativeGroupedAllocationBillingMode Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "in_advance" => CumulativeGroupedAllocationBillingMode.InAdvance, - "in_arrear" => CumulativeGroupedAllocationBillingMode.InArrear, - _ => (CumulativeGroupedAllocationBillingMode)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - CumulativeGroupedAllocationBillingMode value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - CumulativeGroupedAllocationBillingMode.InAdvance => "in_advance", - CumulativeGroupedAllocationBillingMode.InArrear => "in_arrear", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] -public enum CumulativeGroupedAllocationCadence -{ - OneTime, - Monthly, - Quarterly, - SemiAnnual, - Annual, - Custom, -} - -sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter -{ - public override CumulativeGroupedAllocationCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - 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), - }; - } - - public override void Write( - Utf8JsonWriter writer, - CumulativeGroupedAllocationCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - 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)) - ), - }, - options - ); - } -} - -[JsonConverter( - typeof(JsonModelConverter< - CumulativeGroupedAllocationCompositePriceFilter, - CumulativeGroupedAllocationCompositePriceFilterFromRaw - >) -)] -public sealed record class CumulativeGroupedAllocationCompositePriceFilter : 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, - CumulativeGroupedAllocationCompositePriceFilterOperator - > 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 CumulativeGroupedAllocationCompositePriceFilter() { } - - public CumulativeGroupedAllocationCompositePriceFilter( - CumulativeGroupedAllocationCompositePriceFilter cumulativeGroupedAllocationCompositePriceFilter - ) - : base(cumulativeGroupedAllocationCompositePriceFilter) { } - - public CumulativeGroupedAllocationCompositePriceFilter( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - CumulativeGroupedAllocationCompositePriceFilter(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static CumulativeGroupedAllocationCompositePriceFilter FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class CumulativeGroupedAllocationCompositePriceFilterFromRaw - : IFromRawJson -{ - /// - public CumulativeGroupedAllocationCompositePriceFilter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => CumulativeGroupedAllocationCompositePriceFilter.FromRawUnchecked(rawData); -} - -/// -/// The property of the price to filter on. -/// -[JsonConverter(typeof(CumulativeGroupedAllocationCompositePriceFilterFieldConverter))] -public enum CumulativeGroupedAllocationCompositePriceFilterField -{ - PriceID, - ItemID, - PriceType, - Currency, - PricingUnitID, -} - -sealed class CumulativeGroupedAllocationCompositePriceFilterFieldConverter - : JsonConverter -{ - public override CumulativeGroupedAllocationCompositePriceFilterField Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - 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), - }; - } - - public override void Write( - Utf8JsonWriter writer, - CumulativeGroupedAllocationCompositePriceFilterField value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - 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)) - ), - }, - options - ); - } -} - -/// -/// Should prices that match the filter be included or excluded. -/// -[JsonConverter(typeof(CumulativeGroupedAllocationCompositePriceFilterOperatorConverter))] -public enum CumulativeGroupedAllocationCompositePriceFilterOperator -{ - Includes, - Excludes, -} - -sealed class CumulativeGroupedAllocationCompositePriceFilterOperatorConverter - : JsonConverter -{ - public override CumulativeGroupedAllocationCompositePriceFilterOperator Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "includes" => CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, - "excludes" => CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes, - _ => (CumulativeGroupedAllocationCompositePriceFilterOperator)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - CumulativeGroupedAllocationCompositePriceFilterOperator value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - CumulativeGroupedAllocationCompositePriceFilterOperator.Includes => "includes", - CumulativeGroupedAllocationCompositePriceFilterOperator.Excludes => "excludes", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -[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" + "Data did not match any variant of CumulativeGroupedBulkConversionRateConfig" ); } } @@ -36517,16 +38826,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,16 +38854,16 @@ 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) - { - 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() { @@ -36562,13 +38871,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -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 +38955,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 +38971,113 @@ 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() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulkCumulativeGroupedBulkConfig( + CumulativeGroupedBulkCumulativeGroupedBulkConfig cumulativeGroupedBulkCumulativeGroupedBulkConfig + ) + : base(cumulativeGroupedBulkCumulativeGroupedBulkConfig) { } +#pragma warning restore CS8618 + + 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 +39090,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 +39118,40 @@ 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( + CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue cumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue ) - : base(cumulativeGroupedAllocationConfig) { } + : base(cumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue) { } +#pragma warning restore CS8618 - 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 +39159,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 +39186,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 +39203,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 +39215,111 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class PriceMinimum : JsonModel +/// +/// 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) +)] +public sealed record class CumulativeGroupedAllocation : JsonModel { public required string ID { @@ -36840,40 +39353,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 +39405,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 +39437,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 +39584,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 +39617,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); } } @@ -37138,6 +39655,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() { @@ -37154,6 +39688,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 +39700,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"); } @@ -37175,30 +39714,34 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.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"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [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) { } +#pragma warning restore CS8618 [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 +39749,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 +39790,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 +39806,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 +39817,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(PriceMinimumCadenceConverter))] -public enum PriceMinimumCadence +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] +public enum CumulativeGroupedAllocationCadence { OneTime, Monthly, @@ -37281,9 +39828,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 +39839,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 +39859,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 +39876,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 +39900,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 +39942,33 @@ public override void Validate() _ = this.Values; } - public PriceMinimumCompositePriceFilter() { } + public CumulativeGroupedAllocationCompositePriceFilter() { } - public PriceMinimumCompositePriceFilter( - PriceMinimumCompositePriceFilter priceMinimumCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationCompositePriceFilter( + CumulativeGroupedAllocationCompositePriceFilter cumulativeGroupedAllocationCompositePriceFilter ) - : base(priceMinimumCompositePriceFilter) { } + : base(cumulativeGroupedAllocationCompositePriceFilter) { } +#pragma warning restore CS8618 - 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 +39976,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 +39998,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 +40009,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 +40028,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 +40046,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 +40064,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 +40080,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 +40091,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 +40109,7 @@ public JsonElement Json } } - public PriceMinimumConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -37560,7 +40118,7 @@ public PriceMinimumConversionRateConfig( this._element = element; } - public PriceMinimumConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -37569,7 +40127,7 @@ public PriceMinimumConversionRateConfig( this._element = element; } - public PriceMinimumConversionRateConfig(JsonElement element) + public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -37651,7 +40209,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 +40245,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,16 +40273,16 @@ 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) - { - 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() { @@ -37732,13 +40290,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -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 +40374,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 +40390,129 @@ 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) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationConfig( + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + ) + : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 - 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 +40520,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 +40537,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)) ), @@ -37951,6 +40549,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 { @@ -38288,6 +40988,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() { @@ -38330,6 +41045,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -38340,11 +41056,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" @@ -38550,10 +41269,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) { @@ -38879,10 +41601,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() { @@ -38890,7 +41612,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class MinimumCompositeConversionRateConfigConverter @@ -39030,10 +41765,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) { @@ -39120,6 +41858,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 { @@ -39451,6 +42285,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() { @@ -39488,6 +42337,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -39498,11 +42348,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" @@ -39703,8 +42556,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) { @@ -40029,10 +42885,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() { @@ -40040,7 +42896,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PercentConversionRateConfigConverter : JsonConverter @@ -40152,8 +43021,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) { @@ -40236,6 +43108,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 { @@ -40569,6 +43534,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() { @@ -40611,6 +43591,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -40621,11 +43602,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" @@ -40829,10 +43813,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) { @@ -41157,10 +44144,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() { @@ -41168,7 +44155,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class EventOutputConversionRateConfigConverter @@ -41312,8 +44312,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) { @@ -41397,3 +44400,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/PriceInterval.cs b/src/Orb/Models/PriceInterval.cs index 88b9049dc..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,12 +231,16 @@ public override void Validate() this.Price.Validate(); _ = this.StartDate; _ = this.UsageCustomerIds; + _ = this.MetricParameterOverrides; } 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..e873474ad 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) { @@ -315,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() { @@ -326,7 +329,21 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + double _ => 1, + bool _ => 2, + _ => -1, + }; + } } sealed class GroupingValueConverter : JsonConverter @@ -353,7 +370,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) { @@ -362,7 +379,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/Prices/ExternalPriceID/ExternalPriceIDFetchParams.cs b/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDFetchParams.cs index db8f76d6f..4759202b9 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,36 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Prices/ExternalPriceID/ExternalPriceIDUpdateParams.cs b/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDUpdateParams.cs index dcbbe1f77..88b44c125 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,38 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +162,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 fcf7c47b7..86c6df858 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,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +152,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -173,7 +213,6 @@ public string Currency newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.Currency, newFloatingCumulativeGroupedBulkPrice: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, newFloatingMinimumCompositePrice: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -214,7 +253,6 @@ public string ItemID newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.ItemID, newFloatingCumulativeGroupedBulkPrice: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, newFloatingMinimumCompositePrice: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -255,7 +293,6 @@ public string Name newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.Name, newFloatingCumulativeGroupedBulkPrice: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, newFloatingMinimumCompositePrice: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -296,7 +333,6 @@ public string? BillableMetricID newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.BillableMetricID, newFloatingCumulativeGroupedBulkPrice: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, newFloatingMinimumCompositePrice: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -337,7 +373,6 @@ public bool? BilledInAdvance newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.BilledInAdvance, newFloatingCumulativeGroupedBulkPrice: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, newFloatingMinimumCompositePrice: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -378,7 +413,6 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.BillingCycleConfiguration, newFloatingCumulativeGroupedBulkPrice: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, newFloatingMinimumCompositePrice: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -419,7 +453,6 @@ public double? ConversionRate newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.ConversionRate, newFloatingCumulativeGroupedBulkPrice: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, newFloatingMinimumCompositePrice: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -462,7 +495,6 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration x.DimensionalPriceConfiguration, newFloatingCumulativeGroupedBulkPrice: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, newFloatingMinimumCompositePrice: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -503,7 +535,6 @@ public string? ExternalPriceID newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.ExternalPriceID, newFloatingCumulativeGroupedBulkPrice: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, newFloatingMinimumCompositePrice: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -544,7 +575,6 @@ public double? FixedPriceQuantity newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.FixedPriceQuantity, newFloatingCumulativeGroupedBulkPrice: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, newFloatingMinimumCompositePrice: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -585,7 +615,6 @@ public string? InvoiceGroupingKey newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.InvoiceGroupingKey, newFloatingCumulativeGroupedBulkPrice: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, newFloatingMinimumCompositePrice: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -627,7 +656,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 @@ -635,6 +663,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; @@ -653,7 +721,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 +823,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 +865,7 @@ public Body(NewFloatingCumulativeGroupedBulkPrice value, JsonElement? element = this._element = element; } - public Body( - global::Orb.Models.Prices.CumulativeGroupedAllocation value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public Body(global::Orb.Models.Prices.Minimum value, JsonElement? element = null) + public Body(CumulativeGroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -821,13 +877,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 +959,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 +1346,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 +1507,24 @@ public bool TryPickNewFloatingCumulativeGroupedBulkPrice( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `global::Orb.Models.Prices.CumulativeGroupedAllocation` + /// // `value` is of type `CumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out global::Orb.Models.Prices.CumulativeGroupedAllocation? value + [NotNullWhen(true)] out CumulativeGroupedAllocation? value ) { - value = this.Value as global::Orb.Models.Prices.CumulativeGroupedAllocation; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Prices.Minimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out global::Orb.Models.Prices.Minimum? value) - { - value = this.Value as global::Orb.Models.Prices.Minimum; + value = this.Value as CumulativeGroupedAllocation; return value != null; } @@ -1520,45 +1553,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 +1610,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 +1627,17 @@ public bool TryPickEventOutput( /// (NewFloatingBulkWithProrationPrice value) => {...}, /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Prices.GroupedWithMinMaxThresholds value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, /// (NewFloatingGroupedTieredPackagePrice value) => {...}, /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Prices.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Prices.Minimum value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Prices.Percent value) => {...}, - /// (global::Orb.Models.Prices.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -1616,7 +1646,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 +1663,17 @@ public void Switch( System::Action newFloatingBulkWithProrationPrice, System::Action newFloatingGroupedWithProratedMinimumPrice, System::Action newFloatingGroupedWithMeteredMinimumPrice, - System::Action groupedWithMinMaxThresholds, + System::Action groupedWithMinMaxThresholds, System::Action newFloatingMatrixWithDisplayNamePrice, System::Action newFloatingGroupedTieredPackagePrice, System::Action newFloatingMaxGroupTieredPackagePrice, System::Action newFloatingScalableMatrixWithUnitPricingPrice, System::Action newFloatingScalableMatrixWithTieredPricingPrice, System::Action newFloatingCumulativeGroupedBulkPrice, - System::Action cumulativeGroupedAllocation, - System::Action minimum, + System::Action cumulativeGroupedAllocation, System::Action newFloatingMinimumCompositePrice, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -1658,7 +1687,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 +1738,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 +1759,16 @@ public void Switch( case NewFloatingCumulativeGroupedBulkPrice value: newFloatingCumulativeGroupedBulkPrice(value); break; - case global::Orb.Models.Prices.CumulativeGroupedAllocation value: + case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case global::Orb.Models.Prices.Minimum value: - minimum(value); - break; case NewFloatingMinimumCompositePrice value: newFloatingMinimumCompositePrice(value); break; - case global::Orb.Models.Prices.Percent value: + case Percent value: percent(value); break; - case global::Orb.Models.Prices.EventOutput value: + case EventOutput value: eventOutput(value); break; default: @@ -1768,7 +1794,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 +1811,17 @@ public void Switch( /// (NewFloatingBulkWithProrationPrice value) => {...}, /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Prices.GroupedWithMinMaxThresholds value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, /// (NewFloatingGroupedTieredPackagePrice value) => {...}, /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Prices.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Prices.Minimum value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Prices.Percent value) => {...}, - /// (global::Orb.Models.Prices.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -1805,7 +1830,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 +1859,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 +1881,10 @@ public T Match( NewFloatingCumulativeGroupedBulkPrice, T > newFloatingCumulativeGroupedBulkPrice, - System::Func< - global::Orb.Models.Prices.CumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, + System::Func cumulativeGroupedAllocation, System::Func newFloatingMinimumCompositePrice, - System::Func percent, - System::Func eventOutput + System::Func percent, + System::Func eventOutput ) { return this.Value switch @@ -1874,7 +1892,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 +1918,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 +1935,10 @@ public T Match( NewFloatingCumulativeGroupedBulkPrice value => newFloatingCumulativeGroupedBulkPrice( value ), - global::Orb.Models.Prices.CumulativeGroupedAllocation value => - cumulativeGroupedAllocation(value), - global::Orb.Models.Prices.Minimum value => minimum(value), + CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), NewFloatingMinimumCompositePrice value => newFloatingMinimumCompositePrice(value), - global::Orb.Models.Prices.Percent value => percent(value), - global::Orb.Models.Prices.EventOutput value => eventOutput(value), + Percent value => percent(value), + EventOutput value => eventOutput(value), _ => throw new OrbInvalidDataException("Data did not match any variant of Body"), }; } @@ -1934,8 +1949,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 +1986,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 +2002,13 @@ public static implicit operator Body(NewFloatingScalableMatrixWithTieredPricingP public static implicit operator Body(NewFloatingCumulativeGroupedBulkPrice value) => new(value); - public static implicit operator Body( - global::Orb.Models.Prices.CumulativeGroupedAllocation value - ) => new(value); - - public static implicit operator Body(global::Orb.Models.Prices.Minimum value) => new(value); + public static implicit operator Body(CumulativeGroupedAllocation value) => new(value); public static implicit operator Body(NewFloatingMinimumCompositePrice value) => new(value); - public static implicit operator Body(global::Orb.Models.Prices.Percent value) => new(value); + public static implicit operator Body(Percent value) => new(value); - public static implicit operator Body(global::Orb.Models.Prices.EventOutput value) => new(value); + public static implicit operator Body(EventOutput value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2059,17 +2067,16 @@ public override void Validate() (newFloatingCumulativeGroupedBulkPrice) => newFloatingCumulativeGroupedBulkPrice.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newFloatingMinimumCompositePrice) => newFloatingMinimumCompositePrice.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.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() { @@ -2077,7 +2084,49 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 @@ -2171,11 +2220,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2557,11 +2605,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2718,34 +2765,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -2786,11 +2809,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2809,11 +2828,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -2841,25 +2856,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 +2875,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 +2996,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); } } @@ -3072,6 +3076,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 @@ -3120,6 +3137,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -3128,8 +3146,11 @@ public BulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public BulkWithFilters(global::Orb.Models.Prices.BulkWithFilters bulkWithFilters) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithFilters(BulkWithFilters bulkWithFilters) : base(bulkWithFilters) { } +#pragma warning restore CS8618 public BulkWithFilters(IReadOnlyDictionary rawData) { @@ -3146,49 +3167,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 +3209,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,10 +3240,11 @@ public override void Validate() public BulkWithFiltersConfig() { } - public BulkWithFiltersConfig( - global::Orb.Models.Prices.BulkWithFiltersConfig bulkWithFiltersConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) : base(bulkWithFiltersConfig) { } +#pragma warning restore CS8618 public BulkWithFiltersConfig(IReadOnlyDictionary rawData) { @@ -3249,8 +3259,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 +3268,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,8 +3317,11 @@ public override void Validate() public Filter() { } - public Filter(global::Orb.Models.Prices.Filter filter) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Filter(Filter filter) : base(filter) { } +#pragma warning restore CS8618 public Filter(IReadOnlyDictionary rawData) { @@ -3328,32 +3336,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,8 +3391,11 @@ public override void Validate() public Tier() { } - public Tier(global::Orb.Models.Prices.Tier tier) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Tier(Tier tier) : base(tier) { } +#pragma warning restore CS8618 public Tier(IReadOnlyDictionary rawData) { @@ -3407,10 +3410,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 +3424,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 +3445,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 +3455,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 +3486,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 +3639,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,10 +3666,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Prices.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() { @@ -3683,13 +3677,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -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 +3760,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 +3776,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 +3811,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 +3921,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" ); } @@ -4003,6 +4003,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 @@ -4051,6 +4064,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4059,10 +4073,11 @@ public GroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Prices.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { @@ -4079,8 +4094,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 +4103,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 +4126,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 +4136,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 +4156,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 +4176,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfigFromRaw + GroupedWithMinMaxThresholdsConfig, + GroupedWithMinMaxThresholdsConfigFromRaw >) )] public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel @@ -4237,10 +4245,13 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { @@ -4255,8 +4266,8 @@ public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary - public static global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4264,18 +4275,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 +4442,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,12 +4471,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Prices.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() { @@ -4476,13 +4482,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } 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 +4566,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 +4582,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 +4604,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 +4727,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" ); } @@ -4798,6 +4809,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 @@ -4846,6 +4870,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4854,10 +4879,11 @@ public CumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Prices.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) { @@ -4874,8 +4900,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 +4909,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 +4932,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 +4942,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 +4962,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 +4982,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Prices.CumulativeGroupedAllocationConfig, - global::Orb.Models.Prices.CumulativeGroupedAllocationConfigFromRaw + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw >) )] public sealed record class CumulativeGroupedAllocationConfig : JsonModel @@ -5032,10 +5051,13 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocationConfig( - global::Orb.Models.Prices.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { @@ -5050,8 +5072,8 @@ public CumulativeGroupedAllocationConfig(IReadOnlyDictionary - public static global::Orb.Models.Prices.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5059,18 +5081,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 +5248,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,12 +5277,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Prices.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() { @@ -5271,767 +5288,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class CumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter -{ - public override global::Orb.Models.Prices.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 global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfig( - element - ); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} - -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.Minimum, - global::Orb.Models.Prices.MinimumFromRaw - >) -)] -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 global::Orb.Models.Prices.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(global::Orb.Models.Prices.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 global::Orb.Models.Prices.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class MinimumFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Prices.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.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< - global::Orb.Models.Prices.MinimumConfig, - global::Orb.Models.Prices.MinimumConfigFromRaw - >) -)] -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(global::Orb.Models.Prices.MinimumConfig minimumConfig) - : base(minimumConfig) { } - - public MinimumConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Prices.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } -} - -class MinimumConfigFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Prices.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.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" - ); - } - } + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - /// - /// 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 - ) + int VariantIndex() { return this.Value switch { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" - ), + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, }; } - - 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 +sealed class CumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override MinimumConversionRateConfig? Read( + public override CumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6096,14 +5372,14 @@ JsonSerializerOptions options } default: { - return new MinimumConversionRateConfig(element); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MinimumConversionRateConfig value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -6111,25 +5387,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 +5458,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 +5527,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" ); } @@ -6342,6 +5609,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 @@ -6385,6 +5665,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -6393,8 +5674,11 @@ public Percent() this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Percent(global::Orb.Models.Prices.Percent percent) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Percent(Percent percent) : base(percent) { } +#pragma warning restore CS8618 public Percent(IReadOnlyDictionary rawData) { @@ -6411,27 +5695,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 +5723,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 +5733,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 +5753,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 +5771,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,8 +5795,11 @@ public override void Validate() public PercentConfig() { } - public PercentConfig(global::Orb.Models.Prices.PercentConfig percentConfig) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PercentConfig(PercentConfig percentConfig) : base(percentConfig) { } +#pragma warning restore CS8618 public PercentConfig(IReadOnlyDictionary rawData) { @@ -6535,10 +5814,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 +5828,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 +5994,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,10 +6023,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Prices.PercentConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6758,13 +6034,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -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 +6117,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 +6132,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 +6164,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 +6272,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" ); } @@ -7075,6 +6354,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 @@ -7123,6 +6415,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7131,8 +6424,11 @@ public EventOutput() this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public EventOutput(global::Orb.Models.Prices.EventOutput eventOutput) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutput(EventOutput eventOutput) : base(eventOutput) { } +#pragma warning restore CS8618 public EventOutput(IReadOnlyDictionary rawData) { @@ -7149,27 +6445,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 +6473,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 +6483,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 +6503,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 +6521,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,8 +6576,11 @@ public override void Validate() public EventOutputConfig() { } - public EventOutputConfig(global::Orb.Models.Prices.EventOutputConfig eventOutputConfig) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutputConfig(EventOutputConfig eventOutputConfig) : base(eventOutputConfig) { } +#pragma warning restore CS8618 public EventOutputConfig(IReadOnlyDictionary rawData) { @@ -7305,8 +6595,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 +6611,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 +6777,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,10 +6806,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Prices.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() { @@ -7528,13 +6817,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } 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 +6901,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..dead5094a 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,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +233,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] @@ -255,15 +295,37 @@ 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. /// - 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); } } @@ -287,14 +349,18 @@ public override void Validate() _ = this.ExternalPriceID; _ = this.Filter; _ = this.GroupingKeys; + _ = this.MetricParameterOverrides; this.Price?.Validate(); _ = this.PriceID; } public PriceEvaluation() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluation(PriceEvaluation priceEvaluation) : base(priceEvaluation) { } +#pragma warning restore CS8618 public PriceEvaluation(IReadOnlyDictionary rawData) { @@ -326,7 +392,7 @@ public PriceEvaluation FromRawUnchecked(IReadOnlyDictionary /// /// New floating price request body params. /// -[JsonConverter(typeof(global::Orb.Models.Prices.PriceConverter))] +[JsonConverter(typeof(PriceConverter))] public record class Price : ModelBase { public object? Value { get; } = null; @@ -377,7 +443,6 @@ public string Currency newFloatingScalableMatrixWithTieredPricing: (x) => x.Currency, newFloatingCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, newFloatingMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -418,7 +483,6 @@ public string ItemID newFloatingScalableMatrixWithTieredPricing: (x) => x.ItemID, newFloatingCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, newFloatingMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -459,7 +523,6 @@ public string Name newFloatingScalableMatrixWithTieredPricing: (x) => x.Name, newFloatingCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, newFloatingMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -500,7 +563,6 @@ public string? BillableMetricID newFloatingScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newFloatingCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, newFloatingMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -541,7 +603,6 @@ public bool? BilledInAdvance newFloatingScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newFloatingCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, newFloatingMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -582,7 +643,6 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, newFloatingMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -623,7 +683,6 @@ public double? ConversionRate newFloatingScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newFloatingCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, newFloatingMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -664,7 +723,6 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, newFloatingMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -705,7 +763,6 @@ public string? ExternalPriceID newFloatingScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newFloatingCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, newFloatingMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -746,7 +803,6 @@ public double? FixedPriceQuantity newFloatingScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newFloatingCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, newFloatingMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -787,7 +843,6 @@ public string? InvoiceGroupingKey newFloatingScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newFloatingCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, newFloatingMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -828,7 +883,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 @@ -836,6 +890,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; @@ -1004,12 +1098,6 @@ public Price(PriceCumulativeGroupedAllocation value, JsonElement? element = null this._element = element; } - public Price(global::Orb.Models.Prices.PriceMinimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - public Price(NewFloatingMinimumCompositePrice value, JsonElement? element = null) { this.Value = value; @@ -1665,29 +1753,6 @@ public bool TryPickCumulativeGroupedAllocation( return value != null; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Prices.PriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] out global::Orb.Models.Prices.PriceMinimum? value - ) - { - value = this.Value as global::Orb.Models.Prices.PriceMinimum; - return value != null; - } - /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . @@ -1795,7 +1860,6 @@ public bool TryPickEventOutput([NotNullWhen(true)] out PriceEventOutput? value) /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceCumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Prices.PriceMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PricePercent value) => {...}, /// (PriceEventOutput value) => {...} @@ -1832,7 +1896,6 @@ public void Switch( System::Action newFloatingScalableMatrixWithTieredPricing, System::Action newFloatingCumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, System::Action newFloatingMinimumComposite, System::Action percent, System::Action eventOutput @@ -1924,9 +1987,6 @@ public void Switch( case PriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case global::Orb.Models.Prices.PriceMinimum value: - minimum(value); - break; case NewFloatingMinimumCompositePrice value: newFloatingMinimumComposite(value); break; @@ -1984,7 +2044,6 @@ public void Switch( /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceCumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Prices.PriceMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PricePercent value) => {...}, /// (PriceEventOutput value) => {...} @@ -2036,7 +2095,6 @@ public T Match( > newFloatingScalableMatrixWithTieredPricing, System::Func newFloatingCumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func minimum, System::Func newFloatingMinimumComposite, System::Func percent, System::Func eventOutput @@ -2079,7 +2137,6 @@ public T Match( newFloatingScalableMatrixWithTieredPricing(value), NewFloatingCumulativeGroupedBulkPrice value => newFloatingCumulativeGroupedBulk(value), PriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - global::Orb.Models.Prices.PriceMinimum value => minimum(value), NewFloatingMinimumCompositePrice value => newFloatingMinimumComposite(value), PricePercent value => percent(value), PriceEventOutput value => eventOutput(value), @@ -2087,126 +2144,76 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingUnitPrice value) => - new(value); - - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingTieredPrice value) => - new(value); + public static implicit operator Price(NewFloatingUnitPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingBulkPrice value) => - new(value); + public static implicit operator Price(NewFloatingTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(PriceBulkWithFilters value) => - new(value); + public static implicit operator Price(NewFloatingBulkPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingPackagePrice value - ) => new(value); + public static implicit operator Price(PriceBulkWithFilters value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingMatrixPrice value) => - new(value); + public static implicit operator Price(NewFloatingPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingThresholdTotalAmountPrice value - ) => new(value); + public static implicit operator Price(NewFloatingMatrixPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewFloatingThresholdTotalAmountPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedTieredPrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredWithMinimumPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredPackageWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingPackageWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredPackageWithMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingUnitWithPercentPrice value - ) => new(value); + public static implicit operator Price(NewFloatingPackageWithAllocationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingMatrixWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingUnitWithPercentPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingMatrixWithAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingUnitWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedAllocationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingUnitWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingBulkWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedWithProratedMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingBulkWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedWithMeteredMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedWithProratedMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - PriceGroupedWithMinMaxThresholds value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedWithMeteredMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingMatrixWithDisplayNamePrice value - ) => new(value); + public static implicit operator Price(PriceGroupedWithMinMaxThresholds value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewFloatingMatrixWithDisplayNamePrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingMaxGroupTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingScalableMatrixWithUnitPricingPrice value - ) => new(value); + public static implicit operator Price(NewFloatingMaxGroupTieredPackagePrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingScalableMatrixWithTieredPricingPrice value - ) => new(value); + public static implicit operator Price(NewFloatingScalableMatrixWithUnitPricingPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingCumulativeGroupedBulkPrice value - ) => new(value); + public static implicit operator Price(NewFloatingScalableMatrixWithTieredPricingPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - PriceCumulativeGroupedAllocation value - ) => new(value); + public static implicit operator Price(NewFloatingCumulativeGroupedBulkPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - global::Orb.Models.Prices.PriceMinimum value - ) => new(value); + public static implicit operator Price(PriceCumulativeGroupedAllocation value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingMinimumCompositePrice value - ) => new(value); + public static implicit operator Price(NewFloatingMinimumCompositePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(PricePercent value) => - new(value); + public static implicit operator Price(PricePercent value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(PriceEventOutput value) => - new(value); + public static implicit operator Price(PriceEventOutput value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2257,17 +2264,16 @@ public override void Validate() newFloatingScalableMatrixWithTieredPricing.Validate(), (newFloatingCumulativeGroupedBulk) => newFloatingCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newFloatingMinimumComposite) => newFloatingMinimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() ); } - public virtual bool Equals(global::Orb.Models.Prices.Price? other) - { - 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() { @@ -2275,12 +2281,54 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 +sealed class PriceConverter : JsonConverter { - public override global::Orb.Models.Prices.Price? Read( + public override Price? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2932,29 +2980,6 @@ JsonSerializerOptions options return new(element); } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } case "minimum_composite": { try @@ -3020,16 +3045,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); } @@ -3261,6 +3282,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 @@ -3309,6 +3343,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -3317,8 +3352,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) { @@ -3420,10 +3458,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 @@ -3504,10 +3545,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 @@ -3588,10 +3632,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 @@ -3880,10 +3927,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() { @@ -3891,7 +3938,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceBulkWithFiltersConversionRateConfigConverter @@ -4208,6 +4268,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 @@ -4256,6 +4329,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4264,10 +4338,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) { @@ -4436,10 +4513,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 @@ -4665,10 +4745,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() { @@ -4676,7 +4756,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceGroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -4993,6 +5086,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 @@ -5041,6 +5147,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -5049,10 +5156,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) { @@ -5221,10 +5331,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 @@ -5450,10 +5563,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() { @@ -5461,7 +5574,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceCumulativeGroupedAllocationConversionRateConfigConverter @@ -5547,25 +5673,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.PriceMinimum, - global::Orb.Models.Prices.PriceMinimumFromRaw - >) -)] -public sealed record class PriceMinimum : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PricePercent : 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); } } @@ -5596,19 +5715,6 @@ public required string ItemID 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 /// @@ -5636,747 +5742,16 @@ public required string Name } /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// Configuration for percent pricing /// - public string? BillableMetricID + public required PricePercentPercentConfig PercentConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); + return this._rawData.GetNotNullClass("percent_config"); } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } - - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } - } - - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public global::Orb.Models.Prices.PriceMinimumConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } - - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } - - /// - /// An alias for the price. - /// - public string? ExternalPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } - } - - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } - - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } - } - - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } - - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - public override void Validate() - { - this.Cadence.Validate(); - _ = this.Currency; - _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - } - - public PriceMinimum() - { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); - } - - public PriceMinimum(global::Orb.Models.Prices.PriceMinimum priceMinimum) - : base(priceMinimum) { } - - public PriceMinimum(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("minimum"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - PriceMinimum(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Prices.PriceMinimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class PriceMinimumFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Prices.PriceMinimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.PriceMinimum.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(global::Orb.Models.Prices.PriceMinimumCadenceConverter))] -public enum PriceMinimumCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class PriceMinimumCadenceConverter - : JsonConverter -{ - public override global::Orb.Models.Prices.PriceMinimumCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => global::Orb.Models.Prices.PriceMinimumCadence.Annual, - "semi_annual" => global::Orb.Models.Prices.PriceMinimumCadence.SemiAnnual, - "monthly" => global::Orb.Models.Prices.PriceMinimumCadence.Monthly, - "quarterly" => global::Orb.Models.Prices.PriceMinimumCadence.Quarterly, - "one_time" => global::Orb.Models.Prices.PriceMinimumCadence.OneTime, - "custom" => global::Orb.Models.Prices.PriceMinimumCadence.Custom, - _ => (global::Orb.Models.Prices.PriceMinimumCadence)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Prices.PriceMinimumCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - global::Orb.Models.Prices.PriceMinimumCadence.Annual => "annual", - global::Orb.Models.Prices.PriceMinimumCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Prices.PriceMinimumCadence.Monthly => "monthly", - global::Orb.Models.Prices.PriceMinimumCadence.Quarterly => "quarterly", - global::Orb.Models.Prices.PriceMinimumCadence.OneTime => "one_time", - global::Orb.Models.Prices.PriceMinimumCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -/// -/// Configuration for minimum pricing -/// -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class PriceMinimumMinimumConfig : JsonModel -{ - /// - /// The minimum amount to apply - /// - public required string MinimumAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); - } - init { this._rawData.Set("minimum_amount", value); } - } - - /// - /// If true, subtotals from this price are prorated based on the service period - /// - public bool? Prorated - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); - } - init - { - if (value == null) - { - return; - } - - this._rawData.Set("prorated", value); - } - } - - /// - public override void Validate() - { - _ = this.MinimumAmount; - _ = this.Prorated; - } - - public PriceMinimumMinimumConfig() { } - - public PriceMinimumMinimumConfig(PriceMinimumMinimumConfig priceMinimumMinimumConfig) - : base(priceMinimumMinimumConfig) { } - - public PriceMinimumMinimumConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - PriceMinimumMinimumConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static PriceMinimumMinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public PriceMinimumMinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } -} - -class PriceMinimumMinimumConfigFromRaw : IFromRawJson -{ - /// - public PriceMinimumMinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => PriceMinimumMinimumConfig.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(global::Orb.Models.Prices.PriceMinimumConversionRateConfigConverter))] -public record class PriceMinimumConversionRateConfig : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } - - public PriceMinimumConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public PriceMinimumConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public PriceMinimumConversionRateConfig(JsonElement element) - { - this._element = element; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) - { - value = this.Value as SharedUnitConversionRateConfig; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) - { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.Value) - { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of PriceMinimumConversionRateConfig" - ); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) - { - return this.Value switch - { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of PriceMinimumConversionRateConfig" - ), - }; - } - - public static implicit operator global::Orb.Models.Prices.PriceMinimumConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); - - public static implicit operator global::Orb.Models.Prices.PriceMinimumConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of PriceMinimumConversionRateConfig" - ); - } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } - - public virtual bool Equals(global::Orb.Models.Prices.PriceMinimumConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class PriceMinimumConversionRateConfigConverter - : JsonConverter -{ - public override global::Orb.Models.Prices.PriceMinimumConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } - - switch (conversionRateType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new global::Orb.Models.Prices.PriceMinimumConversionRateConfig(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Prices.PriceMinimumConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} - -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class PricePercent : JsonModel -{ - /// - /// 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); } - } - - /// - /// 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); } + init { this._rawData.Set("percent_config", value); } } /// @@ -6520,6 +5895,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 @@ -6563,6 +5951,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -6571,8 +5960,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) { @@ -6691,8 +6083,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) { @@ -6919,10 +6314,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() { @@ -6930,7 +6325,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PricePercentConversionRateConfigConverter @@ -7242,6 +6650,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 @@ -7290,6 +6711,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7298,8 +6720,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) { @@ -7454,10 +6879,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) { @@ -7684,10 +7112,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() { @@ -7695,7 +7123,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceEventOutputConversionRateConfigConverter 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/PriceEvaluateParams.cs b/src/Orb/Models/Prices/PriceEvaluateParams.cs index 84d73a41b..5c632719d 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 @@ -136,8 +140,32 @@ 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 + [SetsRequiredMembers] public PriceEvaluateParams(PriceEvaluateParams priceEvaluateParams) : base(priceEvaluateParams) { @@ -145,6 +173,7 @@ public PriceEvaluateParams(PriceEvaluateParams priceEvaluateParams) this._rawBodyData = new(priceEvaluateParams._rawBodyData); } +#pragma warning restore CS8618 public PriceEvaluateParams( IReadOnlyDictionary rawHeaderData, @@ -185,6 +214,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +272,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..4b9811f33 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,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +250,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] @@ -308,8 +348,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) { @@ -398,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. /// @@ -432,16 +497,20 @@ public override void Validate() _ = this.ExternalPriceID; _ = this.Filter; _ = this.GroupingKeys; + _ = this.MetricParameterOverrides; this.Price?.Validate(); _ = this.PriceID; } public PriceEvaluatePreviewEventsParamsPriceEvaluation() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluation( PriceEvaluatePreviewEventsParamsPriceEvaluation priceEvaluatePreviewEventsParamsPriceEvaluation ) : base(priceEvaluatePreviewEventsParamsPriceEvaluation) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluation( IReadOnlyDictionary rawData @@ -530,7 +599,6 @@ public string Currency newFloatingScalableMatrixWithTieredPricing: (x) => x.Currency, newFloatingCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, newFloatingMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -571,7 +639,6 @@ public string ItemID newFloatingScalableMatrixWithTieredPricing: (x) => x.ItemID, newFloatingCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, newFloatingMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -612,7 +679,6 @@ public string Name newFloatingScalableMatrixWithTieredPricing: (x) => x.Name, newFloatingCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, newFloatingMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -653,7 +719,6 @@ public string? BillableMetricID newFloatingScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newFloatingCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, newFloatingMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -694,7 +759,6 @@ public bool? BilledInAdvance newFloatingScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newFloatingCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, newFloatingMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -735,7 +799,6 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, newFloatingMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -776,7 +839,6 @@ public double? ConversionRate newFloatingScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newFloatingCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, newFloatingMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -817,7 +879,6 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, newFloatingMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -858,7 +919,6 @@ public string? ExternalPriceID newFloatingScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newFloatingCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, newFloatingMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -899,7 +959,6 @@ public double? FixedPriceQuantity newFloatingScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newFloatingCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, newFloatingMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -940,7 +999,6 @@ public string? InvoiceGroupingKey newFloatingScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newFloatingCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, newFloatingMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -981,7 +1039,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 @@ -989,6 +1046,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 @@ -1241,15 +1338,6 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( this._element = element; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( NewFloatingMinimumCompositePrice value, JsonElement? element = null @@ -1923,29 +2011,6 @@ out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocat return value != null; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum? value - ) - { - value = this.Value as PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum; - return value != null; - } - /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . @@ -2058,7 +2123,6 @@ out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput? value /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value) => {...} @@ -2095,7 +2159,6 @@ public void Switch( System::Action newFloatingScalableMatrixWithTieredPricing, System::Action newFloatingCumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, System::Action newFloatingMinimumComposite, System::Action percent, System::Action eventOutput @@ -2187,9 +2250,6 @@ public void Switch( case PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value: - minimum(value); - break; case NewFloatingMinimumCompositePrice value: newFloatingMinimumComposite(value); break; @@ -2249,7 +2309,6 @@ public void Switch( /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value) => {...}, /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value) => {...} @@ -2310,7 +2369,6 @@ public T Match( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation, T > cumulativeGroupedAllocation, - System::Func minimum, System::Func newFloatingMinimumComposite, System::Func percent, System::Func eventOutput @@ -2356,7 +2414,6 @@ public T Match( NewFloatingCumulativeGroupedBulkPrice value => newFloatingCumulativeGroupedBulk(value), PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value => minimum(value), NewFloatingMinimumCompositePrice value => newFloatingMinimumComposite(value), PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value => percent(value), PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value => eventOutput( @@ -2480,10 +2537,6 @@ public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationP PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value ) => new(value); - public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value - ) => new(value); - public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPrice( NewFloatingMinimumCompositePrice value ) => new(value); @@ -2547,17 +2600,16 @@ public override void Validate() newFloatingScalableMatrixWithTieredPricing.Validate(), (newFloatingCumulativeGroupedBulk) => newFloatingCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newFloatingMinimumComposite) => newFloatingMinimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() ); } - public virtual bool Equals(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() { @@ -2565,7 +2617,49 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 @@ -3226,29 +3320,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 @@ -3572,6 +3643,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 @@ -3620,6 +3704,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -3628,10 +3713,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 @@ -3741,12 +3829,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 @@ -3834,12 +3925,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 @@ -3927,12 +4021,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 @@ -4250,10 +4347,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() { @@ -4261,7 +4358,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersConversionRateConfigConverter @@ -4587,6 +4697,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 @@ -4635,6 +4758,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4643,10 +4767,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 @@ -4841,12 +4968,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 @@ -5081,10 +5211,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() { @@ -5092,7 +5222,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -5418,6 +5561,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 @@ -5466,6 +5622,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -5474,10 +5631,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 @@ -5672,12 +5832,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 @@ -5912,10 +6075,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() { @@ -5923,7 +6086,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfigConverter @@ -6013,25 +6189,25 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumFromRaw + PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent, + PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentFromRaw >) )] -public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum : JsonModel +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent : JsonModel { /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadence > Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -6064,44 +6240,44 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// The pricing model type /// - public required PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentPercentConfig 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); } } /// @@ -6163,12 +6339,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig? ConversionRateConfig + public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6245,6 +6421,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 @@ -6272,12 +6461,12 @@ public override void Validate() this.Cadence.Validate(); _ = this.Currency; _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; + this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -6288,31 +6477,35 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum() + public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum priceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent( + PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent priceEvaluatePreviewEventsParamsPriceEvaluationPricePercent ) - : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum) { } + : base(priceEvaluatePreviewEventsParamsPriceEvaluationPricePercent) { } +#pragma warning restore CS8618 - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum( + PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent( FrozenDictionary rawData ) { @@ -6320,8 +6513,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum FromRawUnchecked( + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6329,810 +6522,13 @@ IReadOnlyDictionary rawData } } -class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumFromRaw - : IFromRawJson +class PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentFromRaw + : IFromRawJson { /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum FromRawUnchecked( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent 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, - PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentFromRaw - >) -)] -public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent : JsonModel -{ - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum< - string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadence - > 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); } - } - - /// - /// 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentPercentConfig 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } - - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } - - /// - /// An alias for the price. - /// - public string? ExternalPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } - } - - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } - - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } - } - - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } - - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - public override void Validate() - { - this.Cadence.Validate(); - _ = this.Currency; - _ = this.ItemID; - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - this.PercentConfig.Validate(); - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - } - - public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent() - { - this.ModelType = JsonSerializer.SerializeToElement("percent"); - } - - public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent( - PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent priceEvaluatePreviewEventsParamsPriceEvaluationPricePercent - ) - : base(priceEvaluatePreviewEventsParamsPriceEvaluationPricePercent) { } - - public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("percent"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentFromRaw - : IFromRawJson -{ - /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent.FromRawUnchecked(rawData); + ) => PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent.FromRawUnchecked(rawData); } /// @@ -7237,10 +6633,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 @@ -7482,10 +6881,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() { @@ -7493,7 +6892,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentConversionRateConfigConverter @@ -7819,6 +7231,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 @@ -7867,6 +7292,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7875,10 +7301,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 @@ -8055,10 +7484,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 @@ -8302,10 +7734,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() { @@ -8313,7 +7745,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutputConversionRateConfigConverter 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/PriceFetchParams.cs b/src/Orb/Models/Prices/PriceFetchParams.cs index 8b842a32f..7f824500e 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Prices/PriceListPage.cs b/src/Orb/Models/Prices/PriceListPage.cs index efb748688..f0366c21f 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; @@ -64,5 +65,20 @@ 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) + { + 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/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/Prices/PriceListParams.cs b/src/Orb/Models/Prices/PriceListParams.cs index 8b29225f8..d9591c483 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,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(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 +135,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..4a0cc3f6c 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/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/SharedDiscount.cs b/src/Orb/Models/SharedDiscount.cs index 908f8da14..183cf9732 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() { @@ -286,7 +286,22 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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/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..5f502396d 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" @@ -799,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() { @@ -810,7 +813,21 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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/SubscriptionChanges/SubscriptionChangeApplyParams.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeApplyParams.cs index 3c67a0f9c..8fee129df 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,41 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +227,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/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/SubscriptionChangeCancelParams.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeCancelParams.cs index d13c4738a..bb143c890 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,39 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +119,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/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/SubscriptionChangeListPage.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListPage.cs index 7eeed711c..1977e299b 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; @@ -65,5 +66,20 @@ 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) + { + 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/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/SubscriptionChangeListParams.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListParams.cs index 943363b6f..9d9516f0c 100644 --- a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListParams.cs +++ b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeListParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.SubscriptionChanges; /// This endpoint returns a list of pending subscription changes for a customer. /// Use the [Fetch Subscription Change](fetch-subscription-change) endpoint to retrieve /// the expected subscription state after the pending change is applied. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionChangeListParams : ParamsBase +public record class SubscriptionChangeListParams : ParamsBase { /// /// Cursor for pagination. This can be populated by the `next_cursor` value returned @@ -72,22 +76,23 @@ public long? Limit } } - public ApiEnum? Status + public ApiEnum? Status { get { this._rawQueryData.Freeze(); - return this._rawQueryData.GetNullableClass< - ApiEnum - >("status"); + return this._rawQueryData.GetNullableClass>("status"); } init { this._rawQueryData.Set("status", value); } } public SubscriptionChangeListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionChangeListParams(SubscriptionChangeListParams subscriptionChangeListParams) : base(subscriptionChangeListParams) { } +#pragma warning restore CS8618 public SubscriptionChangeListParams( IReadOnlyDictionary rawHeaderData, @@ -122,6 +127,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionChangeListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -140,9 +171,14 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter(typeof(global::Orb.Models.SubscriptionChanges.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { Pending, @@ -150,9 +186,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 +196,22 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "pending" => global::Orb.Models.SubscriptionChanges.Status.Pending, - "applied" => global::Orb.Models.SubscriptionChanges.Status.Applied, - "cancelled" => global::Orb.Models.SubscriptionChanges.Status.Cancelled, - _ => (global::Orb.Models.SubscriptionChanges.Status)(-1), + "pending" => Status.Pending, + "applied" => Status.Applied, + "cancelled" => Status.Cancelled, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.SubscriptionChanges.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.SubscriptionChanges.Status.Pending => "pending", - global::Orb.Models.SubscriptionChanges.Status.Applied => "applied", - global::Orb.Models.SubscriptionChanges.Status.Cancelled => "cancelled", + Status.Pending => "pending", + Status.Applied => "applied", + Status.Cancelled => "cancelled", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/SubscriptionChanges/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/SubscriptionChangeRetrieveParams.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeRetrieveParams.cs index 3f49c3275..051f587f5 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,39 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +123,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/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 642d8032d..bfd824a85 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); } } @@ -76,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) { @@ -101,9 +102,7 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public DiscountOverride( - ApiEnum discountType - ) + public DiscountOverride(ApiEnum discountType) : this() { this.DiscountType = discountType; @@ -117,7 +116,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 +134,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 +151,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..b0f2a7b8b 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); } } @@ -238,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 @@ -292,14 +303,18 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionBulkPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionBulkPrice(NewSubscriptionBulkPrice newSubscriptionBulkPrice) : base(newSubscriptionBulkPrice) { } +#pragma warning restore CS8618 public NewSubscriptionBulkPrice(IReadOnlyDictionary rawData) { @@ -394,15 +409,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 +425,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 +440,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)) ), @@ -623,10 +638,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() { @@ -634,7 +649,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 dab88d879..4f0cd4bb1 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" ); } @@ -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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionBulkWithProrationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionBulkWithProrationPrice( NewSubscriptionBulkWithProrationPrice newSubscriptionBulkWithProrationPrice ) : base(newSubscriptionBulkWithProrationPrice) { } +#pragma warning restore CS8618 public NewSubscriptionBulkWithProrationPrice(IReadOnlyDictionary rawData) { @@ -343,12 +360,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,10 +395,11 @@ public override void Validate() public BulkWithProrationConfig() { } - public BulkWithProrationConfig( - global::Orb.Models.Subscriptions.BulkWithProrationConfig bulkWithProrationConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProrationConfig(BulkWithProrationConfig bulkWithProrationConfig) : base(bulkWithProrationConfig) { } +#pragma warning restore CS8618 public BulkWithProrationConfig(IReadOnlyDictionary rawData) { @@ -401,8 +414,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 +430,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); } /// @@ -469,8 +481,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) { @@ -804,10 +819,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() { @@ -815,7 +830,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 fbc2978a4..edcd7e4a4 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" ); } @@ -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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionCumulativeGroupedBulkPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionCumulativeGroupedBulkPrice( NewSubscriptionCumulativeGroupedBulkPrice newSubscriptionCumulativeGroupedBulkPrice ) : base(newSubscriptionCumulativeGroupedBulkPrice) { } +#pragma warning restore CS8618 public NewSubscriptionCumulativeGroupedBulkPrice( IReadOnlyDictionary rawData @@ -406,28 +423,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,10 +470,11 @@ public override void Validate() public CumulativeGroupedBulkConfig() { } - public CumulativeGroupedBulkConfig( - global::Orb.Models.Subscriptions.CumulativeGroupedBulkConfig cumulativeGroupedBulkConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulkConfig(CumulativeGroupedBulkConfig cumulativeGroupedBulkConfig) : base(cumulativeGroupedBulkConfig) { } +#pragma warning restore CS8618 public CumulativeGroupedBulkConfig(IReadOnlyDictionary rawData) { @@ -474,8 +489,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 +498,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,8 +561,11 @@ public override void Validate() public DimensionValue() { } - public DimensionValue(global::Orb.Models.Subscriptions.DimensionValue dimensionValue) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DimensionValue(DimensionValue dimensionValue) : base(dimensionValue) { } +#pragma warning restore CS8618 public DimensionValue(IReadOnlyDictionary rawData) { @@ -568,21 +580,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); } /// @@ -820,10 +829,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() { @@ -831,7 +842,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 7d50e2604..168dc87b3 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" ); } @@ -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,16 +310,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionGroupedAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionGroupedAllocationPrice( NewSubscriptionGroupedAllocationPrice newSubscriptionGroupedAllocationPrice ) : base(newSubscriptionGroupedAllocationPrice) { } +#pragma warning restore CS8618 public NewSubscriptionGroupedAllocationPrice(IReadOnlyDictionary rawData) { @@ -402,12 +419,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,10 +471,11 @@ public override void Validate() public GroupedAllocationConfig() { } - public GroupedAllocationConfig( - global::Orb.Models.Subscriptions.GroupedAllocationConfig groupedAllocationConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedAllocationConfig(GroupedAllocationConfig groupedAllocationConfig) : base(groupedAllocationConfig) { } +#pragma warning restore CS8618 public GroupedAllocationConfig(IReadOnlyDictionary rawData) { @@ -477,8 +490,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 +499,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); } /// @@ -730,10 +742,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() { @@ -741,7 +753,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 cf6893503..31e34dd78 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" ); } @@ -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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionGroupedTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionGroupedTieredPackagePrice( NewSubscriptionGroupedTieredPackagePrice newSubscriptionGroupedTieredPackagePrice ) : base(newSubscriptionGroupedTieredPackagePrice) { } +#pragma warning restore CS8618 public NewSubscriptionGroupedTieredPackagePrice( IReadOnlyDictionary rawData @@ -406,10 +423,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 +454,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,10 +485,11 @@ public override void Validate() public GroupedTieredPackageConfig() { } - public GroupedTieredPackageConfig( - global::Orb.Models.Subscriptions.GroupedTieredPackageConfig groupedTieredPackageConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackageConfig(GroupedTieredPackageConfig groupedTieredPackageConfig) : base(groupedTieredPackageConfig) { } +#pragma warning restore CS8618 public GroupedTieredPackageConfig(IReadOnlyDictionary rawData) { @@ -488,8 +504,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 +513,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 +526,8 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.GroupedTieredPackageConfigTier, - global::Orb.Models.Subscriptions.GroupedTieredPackageConfigTierFromRaw + GroupedTieredPackageConfigTier, + GroupedTieredPackageConfigTierFromRaw >) )] public sealed record class GroupedTieredPackageConfigTier : JsonModel @@ -549,10 +564,13 @@ public override void Validate() public GroupedTieredPackageConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredPackageConfigTier( - global::Orb.Models.Subscriptions.GroupedTieredPackageConfigTier groupedTieredPackageConfigTier + GroupedTieredPackageConfigTier groupedTieredPackageConfigTier ) : base(groupedTieredPackageConfigTier) { } +#pragma warning restore CS8618 public GroupedTieredPackageConfigTier(IReadOnlyDictionary rawData) { @@ -567,8 +585,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 +594,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); } /// @@ -820,10 +837,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() { @@ -831,7 +850,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 3f6744267..2e433f033 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); } } @@ -244,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 @@ -298,16 +309,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionGroupedTieredPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionGroupedTieredPrice( NewSubscriptionGroupedTieredPrice newSubscriptionGroupedTieredPrice ) : base(newSubscriptionGroupedTieredPrice) { } +#pragma warning restore CS8618 public NewSubscriptionGroupedTieredPrice(IReadOnlyDictionary rawData) { @@ -402,12 +417,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 +436,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,10 +464,11 @@ public override void Validate() public GroupedTieredConfig() { } - public GroupedTieredConfig( - global::Orb.Models.Subscriptions.GroupedTieredConfig groupedTieredConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredConfig(GroupedTieredConfig groupedTieredConfig) : base(groupedTieredConfig) { } +#pragma warning restore CS8618 public GroupedTieredConfig(IReadOnlyDictionary rawData) { @@ -473,8 +483,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 +492,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,10 +537,11 @@ public override void Validate() public GroupedTieredConfigTier() { } - public GroupedTieredConfigTier( - global::Orb.Models.Subscriptions.GroupedTieredConfigTier groupedTieredConfigTier - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredConfigTier(GroupedTieredConfigTier groupedTieredConfigTier) : base(groupedTieredConfigTier) { } +#pragma warning restore CS8618 public GroupedTieredConfigTier(IReadOnlyDictionary rawData) { @@ -552,8 +556,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 +565,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); } /// @@ -803,10 +806,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() { @@ -814,7 +817,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 42f095046..89acb4cc6 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" ); } @@ -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,16 +314,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionGroupedWithMeteredMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionGroupedWithMeteredMinimumPrice( NewSubscriptionGroupedWithMeteredMinimumPrice newSubscriptionGroupedWithMeteredMinimumPrice ) : base(newSubscriptionGroupedWithMeteredMinimumPrice) { } +#pragma warning restore CS8618 public NewSubscriptionGroupedWithMeteredMinimumPrice( IReadOnlyDictionary rawData @@ -410,8 +427,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 +476,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 +509,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) ); @@ -531,10 +544,13 @@ public override void Validate() public GroupedWithMeteredMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMeteredMinimumConfig( - global::Orb.Models.Subscriptions.GroupedWithMeteredMinimumConfig groupedWithMeteredMinimumConfig + GroupedWithMeteredMinimumConfig groupedWithMeteredMinimumConfig ) : base(groupedWithMeteredMinimumConfig) { } +#pragma warning restore CS8618 public GroupedWithMeteredMinimumConfig(IReadOnlyDictionary rawData) { @@ -549,8 +565,8 @@ public GroupedWithMeteredMinimumConfig(IReadOnlyDictionary } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.GroupedWithMeteredMinimumConfig FromRawUnchecked( + /// + public static GroupedWithMeteredMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -558,24 +574,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,8 +617,11 @@ public override void Validate() public ScalingFactor() { } - public ScalingFactor(global::Orb.Models.Subscriptions.ScalingFactor scalingFactor) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalingFactor(ScalingFactor scalingFactor) : base(scalingFactor) { } +#pragma warning restore CS8618 public ScalingFactor(IReadOnlyDictionary rawData) { @@ -623,32 +636,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,8 +688,11 @@ public override void Validate() public UnitAmount() { } - public UnitAmount(global::Orb.Models.Subscriptions.UnitAmount unitAmount) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitAmount(UnitAmount unitAmount) : base(unitAmount) { } +#pragma warning restore CS8618 public UnitAmount(IReadOnlyDictionary rawData) { @@ -699,21 +707,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); } /// @@ -953,10 +958,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() { @@ -964,7 +969,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 77d37738f..f5450a3a6 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" ); } @@ -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,16 +313,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionGroupedWithProratedMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionGroupedWithProratedMinimumPrice( NewSubscriptionGroupedWithProratedMinimumPrice newSubscriptionGroupedWithProratedMinimumPrice ) : base(newSubscriptionGroupedWithProratedMinimumPrice) { } +#pragma warning restore CS8618 public NewSubscriptionGroupedWithProratedMinimumPrice( IReadOnlyDictionary rawData @@ -409,8 +426,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.GroupedWithProratedMinimumConfig, - global::Orb.Models.Subscriptions.GroupedWithProratedMinimumConfigFromRaw + GroupedWithProratedMinimumConfig, + GroupedWithProratedMinimumConfigFromRaw >) )] public sealed record class GroupedWithProratedMinimumConfig : JsonModel @@ -464,10 +481,13 @@ public override void Validate() public GroupedWithProratedMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithProratedMinimumConfig( - global::Orb.Models.Subscriptions.GroupedWithProratedMinimumConfig groupedWithProratedMinimumConfig + GroupedWithProratedMinimumConfig groupedWithProratedMinimumConfig ) : base(groupedWithProratedMinimumConfig) { } +#pragma warning restore CS8618 public GroupedWithProratedMinimumConfig(IReadOnlyDictionary rawData) { @@ -482,8 +502,8 @@ public GroupedWithProratedMinimumConfig(IReadOnlyDictionary } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.GroupedWithProratedMinimumConfig FromRawUnchecked( + /// + public static GroupedWithProratedMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -491,14 +511,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); } /// @@ -738,10 +756,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() { @@ -749,7 +767,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 d505ad247..86842754b 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,14 +305,18 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionMatrixPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionMatrixPrice(NewSubscriptionMatrixPrice newSubscriptionMatrixPrice) : base(newSubscriptionMatrixPrice) { } +#pragma warning restore CS8618 public NewSubscriptionMatrixPrice(IReadOnlyDictionary rawData) { @@ -624,10 +641,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() { @@ -635,7 +652,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 a507d2ac1..30f490d68 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,16 +310,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionMatrixWithAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionMatrixWithAllocationPrice( NewSubscriptionMatrixWithAllocationPrice newSubscriptionMatrixWithAllocationPrice ) : base(newSubscriptionMatrixWithAllocationPrice) { } +#pragma warning restore CS8618 public NewSubscriptionMatrixWithAllocationPrice( IReadOnlyDictionary rawData @@ -636,10 +653,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() { @@ -647,7 +666,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 6f2c58806..9086a1ee0 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" ); } @@ -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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionMatrixWithDisplayNamePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionMatrixWithDisplayNamePrice( NewSubscriptionMatrixWithDisplayNamePrice newSubscriptionMatrixWithDisplayNamePrice ) : base(newSubscriptionMatrixWithDisplayNamePrice) { } +#pragma warning restore CS8618 public NewSubscriptionMatrixWithDisplayNamePrice( IReadOnlyDictionary rawData @@ -406,10 +423,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 +443,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,10 +473,11 @@ public override void Validate() public MatrixWithDisplayNameConfig() { } - public MatrixWithDisplayNameConfig( - global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfig matrixWithDisplayNameConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayNameConfig(MatrixWithDisplayNameConfig matrixWithDisplayNameConfig) : base(matrixWithDisplayNameConfig) { } +#pragma warning restore CS8618 public MatrixWithDisplayNameConfig(IReadOnlyDictionary rawData) { @@ -476,8 +492,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 +501,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 +514,8 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfigUnitAmount, - global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfigUnitAmountFromRaw + MatrixWithDisplayNameConfigUnitAmount, + MatrixWithDisplayNameConfigUnitAmountFromRaw >) )] public sealed record class MatrixWithDisplayNameConfigUnitAmount : JsonModel @@ -554,10 +569,13 @@ public override void Validate() public MatrixWithDisplayNameConfigUnitAmount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixWithDisplayNameConfigUnitAmount( - global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfigUnitAmount matrixWithDisplayNameConfigUnitAmount + MatrixWithDisplayNameConfigUnitAmount matrixWithDisplayNameConfigUnitAmount ) : base(matrixWithDisplayNameConfigUnitAmount) { } +#pragma warning restore CS8618 public MatrixWithDisplayNameConfigUnitAmount(IReadOnlyDictionary rawData) { @@ -572,8 +590,8 @@ public MatrixWithDisplayNameConfigUnitAmount(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.MatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( + /// + public static MatrixWithDisplayNameConfigUnitAmount FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -582,15 +600,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); } /// @@ -828,10 +843,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() { @@ -839,7 +856,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 c9ee665e1..1b98e3244 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" ); } @@ -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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionMaxGroupTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionMaxGroupTieredPackagePrice( NewSubscriptionMaxGroupTieredPackagePrice newSubscriptionMaxGroupTieredPackagePrice ) : base(newSubscriptionMaxGroupTieredPackagePrice) { } +#pragma warning restore CS8618 public NewSubscriptionMaxGroupTieredPackagePrice( IReadOnlyDictionary rawData @@ -406,10 +423,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 +453,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,10 +484,11 @@ public override void Validate() public MaxGroupTieredPackageConfig() { } - public MaxGroupTieredPackageConfig( - global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfig maxGroupTieredPackageConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackageConfig(MaxGroupTieredPackageConfig maxGroupTieredPackageConfig) : base(maxGroupTieredPackageConfig) { } +#pragma warning restore CS8618 public MaxGroupTieredPackageConfig(IReadOnlyDictionary rawData) { @@ -487,8 +503,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 +512,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 +525,8 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfigTier, - global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfigTierFromRaw + MaxGroupTieredPackageConfigTier, + MaxGroupTieredPackageConfigTierFromRaw >) )] public sealed record class MaxGroupTieredPackageConfigTier : JsonModel @@ -548,10 +563,13 @@ public override void Validate() public MaxGroupTieredPackageConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaxGroupTieredPackageConfigTier( - global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfigTier maxGroupTieredPackageConfigTier + MaxGroupTieredPackageConfigTier maxGroupTieredPackageConfigTier ) : base(maxGroupTieredPackageConfigTier) { } +#pragma warning restore CS8618 public MaxGroupTieredPackageConfigTier(IReadOnlyDictionary rawData) { @@ -566,8 +584,8 @@ public MaxGroupTieredPackageConfigTier(IReadOnlyDictionary } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.MaxGroupTieredPackageConfigTier FromRawUnchecked( + /// + public static MaxGroupTieredPackageConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -575,13 +593,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); } /// @@ -819,10 +836,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() { @@ -830,7 +849,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 7b742fcad..5669ec462 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" ); } @@ -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,16 +310,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionMinimumCompositePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionMinimumCompositePrice( NewSubscriptionMinimumCompositePrice newSubscriptionMinimumCompositePrice ) : base(newSubscriptionMinimumCompositePrice) { } +#pragma warning restore CS8618 public NewSubscriptionMinimumCompositePrice(IReadOnlyDictionary rawData) { @@ -402,12 +419,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,10 +465,11 @@ public override void Validate() public MinimumCompositeConfig() { } - public MinimumCompositeConfig( - global::Orb.Models.Subscriptions.MinimumCompositeConfig minimumCompositeConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MinimumCompositeConfig(MinimumCompositeConfig minimumCompositeConfig) : base(minimumCompositeConfig) { } +#pragma warning restore CS8618 public MinimumCompositeConfig(IReadOnlyDictionary rawData) { @@ -471,8 +484,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 +500,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); } /// @@ -730,10 +742,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() { @@ -741,7 +753,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 7d15cb98a..e99d5e173 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,14 +305,18 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionPackagePrice(NewSubscriptionPackagePrice newSubscriptionPackagePrice) : base(newSubscriptionPackagePrice) { } +#pragma warning restore CS8618 public NewSubscriptionPackagePrice(IReadOnlyDictionary rawData) { @@ -624,10 +641,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() { @@ -635,7 +652,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 f82c1228b..f592bbcf9 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" ); } @@ -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,16 +310,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionPackageWithAllocationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionPackageWithAllocationPrice( NewSubscriptionPackageWithAllocationPrice newSubscriptionPackageWithAllocationPrice ) : base(newSubscriptionPackageWithAllocationPrice) { } +#pragma warning restore CS8618 public NewSubscriptionPackageWithAllocationPrice( IReadOnlyDictionary rawData @@ -452,10 +469,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,10 +513,11 @@ public override void Validate() public PackageWithAllocationConfig() { } - public PackageWithAllocationConfig( - global::Orb.Models.Subscriptions.PackageWithAllocationConfig packageWithAllocationConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PackageWithAllocationConfig(PackageWithAllocationConfig packageWithAllocationConfig) : base(packageWithAllocationConfig) { } +#pragma warning restore CS8618 public PackageWithAllocationConfig(IReadOnlyDictionary rawData) { @@ -517,8 +532,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 +541,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))] @@ -723,10 +737,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() { @@ -734,7 +750,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 7e390a378..4d8ff102f 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" ); } @@ -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,16 +317,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionScalableMatrixWithTieredPricingPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionScalableMatrixWithTieredPricingPrice( NewSubscriptionScalableMatrixWithTieredPricingPrice newSubscriptionScalableMatrixWithTieredPricingPrice ) : base(newSubscriptionScalableMatrixWithTieredPricingPrice) { } +#pragma warning restore CS8618 public NewSubscriptionScalableMatrixWithTieredPricingPrice( IReadOnlyDictionary rawData @@ -463,8 +480,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 +502,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) + ); } } @@ -550,10 +568,13 @@ public override void Validate() public ScalableMatrixWithTieredPricingConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithTieredPricingConfig( - global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfig scalableMatrixWithTieredPricingConfig + ScalableMatrixWithTieredPricingConfig scalableMatrixWithTieredPricingConfig ) : base(scalableMatrixWithTieredPricingConfig) { } +#pragma warning restore CS8618 public ScalableMatrixWithTieredPricingConfig(IReadOnlyDictionary rawData) { @@ -568,8 +589,8 @@ public ScalableMatrixWithTieredPricingConfig(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfig FromRawUnchecked( + /// + public static ScalableMatrixWithTieredPricingConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -578,26 +599,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,10 +653,11 @@ public override void Validate() public MatrixScalingFactor() { } - public MatrixScalingFactor( - global::Orb.Models.Subscriptions.MatrixScalingFactor matrixScalingFactor - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixScalingFactor(MatrixScalingFactor matrixScalingFactor) : base(matrixScalingFactor) { } +#pragma warning restore CS8618 public MatrixScalingFactor(IReadOnlyDictionary rawData) { @@ -658,8 +672,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 +681,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 +693,8 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfigTier, - global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfigTierFromRaw + ScalableMatrixWithTieredPricingConfigTier, + ScalableMatrixWithTieredPricingConfigTierFromRaw >) )] public sealed record class ScalableMatrixWithTieredPricingConfigTier : JsonModel @@ -716,10 +728,13 @@ public override void Validate() public ScalableMatrixWithTieredPricingConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithTieredPricingConfigTier( - global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfigTier scalableMatrixWithTieredPricingConfigTier + ScalableMatrixWithTieredPricingConfigTier scalableMatrixWithTieredPricingConfigTier ) : base(scalableMatrixWithTieredPricingConfigTier) { } +#pragma warning restore CS8618 public ScalableMatrixWithTieredPricingConfigTier( IReadOnlyDictionary rawData @@ -736,8 +751,8 @@ IReadOnlyDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.ScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( + /// + public static ScalableMatrixWithTieredPricingConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -746,15 +761,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( @@ -952,10 +964,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() { @@ -963,7 +975,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 369b5f6fa..0c890415e 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" ); } @@ -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,16 +317,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionScalableMatrixWithUnitPricingPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionScalableMatrixWithUnitPricingPrice( NewSubscriptionScalableMatrixWithUnitPricingPrice newSubscriptionScalableMatrixWithUnitPricingPrice ) : base(newSubscriptionScalableMatrixWithUnitPricingPrice) { } +#pragma warning restore CS8618 public NewSubscriptionScalableMatrixWithUnitPricingPrice( IReadOnlyDictionary rawData @@ -461,8 +478,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 +500,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)); } } @@ -513,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 /// @@ -548,16 +578,20 @@ public override void Validate() item.Validate(); } _ = this.UnitPrice; + _ = this.GroupingKey; _ = this.Prorate; _ = this.SecondDimension; } public ScalableMatrixWithUnitPricingConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithUnitPricingConfig( - global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfig scalableMatrixWithUnitPricingConfig + ScalableMatrixWithUnitPricingConfig scalableMatrixWithUnitPricingConfig ) : base(scalableMatrixWithUnitPricingConfig) { } +#pragma warning restore CS8618 public ScalableMatrixWithUnitPricingConfig(IReadOnlyDictionary rawData) { @@ -572,8 +606,8 @@ public ScalableMatrixWithUnitPricingConfig(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfig FromRawUnchecked( + /// + public static ScalableMatrixWithUnitPricingConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -581,16 +615,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 +628,8 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfigMatrixScalingFactor, - global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw + ScalableMatrixWithUnitPricingConfigMatrixScalingFactor, + ScalableMatrixWithUnitPricingConfigMatrixScalingFactorFromRaw >) )] public sealed record class ScalableMatrixWithUnitPricingConfigMatrixScalingFactor : JsonModel @@ -644,10 +674,13 @@ public override void Validate() public ScalableMatrixWithUnitPricingConfigMatrixScalingFactor() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithUnitPricingConfigMatrixScalingFactor( - global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfigMatrixScalingFactor scalableMatrixWithUnitPricingConfigMatrixScalingFactor + ScalableMatrixWithUnitPricingConfigMatrixScalingFactor scalableMatrixWithUnitPricingConfigMatrixScalingFactor ) : base(scalableMatrixWithUnitPricingConfigMatrixScalingFactor) { } +#pragma warning restore CS8618 public ScalableMatrixWithUnitPricingConfigMatrixScalingFactor( IReadOnlyDictionary rawData @@ -666,8 +699,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.ScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( + /// + public static ScalableMatrixWithUnitPricingConfigMatrixScalingFactor FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -676,15 +709,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( @@ -882,10 +912,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() { @@ -893,7 +923,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 8b368dc93..2aa54ece7 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" ); } @@ -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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionThresholdTotalAmountPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionThresholdTotalAmountPrice( NewSubscriptionThresholdTotalAmountPrice newSubscriptionThresholdTotalAmountPrice ) : base(newSubscriptionThresholdTotalAmountPrice) { } +#pragma warning restore CS8618 public NewSubscriptionThresholdTotalAmountPrice( IReadOnlyDictionary rawData @@ -453,10 +470,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 +478,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,10 +521,11 @@ public override void Validate() public ThresholdTotalAmountConfig() { } - public ThresholdTotalAmountConfig( - global::Orb.Models.Subscriptions.ThresholdTotalAmountConfig thresholdTotalAmountConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ThresholdTotalAmountConfig(ThresholdTotalAmountConfig thresholdTotalAmountConfig) : base(thresholdTotalAmountConfig) { } +#pragma warning restore CS8618 public ThresholdTotalAmountConfig(IReadOnlyDictionary rawData) { @@ -525,8 +540,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 +549,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,8 +602,11 @@ public override void Validate() public ConsumptionTable() { } - public ConsumptionTable(global::Orb.Models.Subscriptions.ConsumptionTable consumptionTable) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ConsumptionTable(ConsumptionTable consumptionTable) : base(consumptionTable) { } +#pragma warning restore CS8618 public ConsumptionTable(IReadOnlyDictionary rawData) { @@ -611,8 +621,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 +630,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))] @@ -816,10 +825,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() { @@ -827,7 +838,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 b343c95c3..19de0a088 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); } } @@ -244,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 @@ -298,16 +309,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionTieredPackagePrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionTieredPackagePrice( NewSubscriptionTieredPackagePrice newSubscriptionTieredPackagePrice ) : base(newSubscriptionTieredPackagePrice) { } +#pragma warning restore CS8618 public NewSubscriptionTieredPackagePrice(IReadOnlyDictionary rawData) { @@ -447,12 +462,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 +481,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,10 +509,11 @@ public override void Validate() public TieredPackageConfig() { } - public TieredPackageConfig( - global::Orb.Models.Subscriptions.TieredPackageConfig tieredPackageConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageConfig(TieredPackageConfig tieredPackageConfig) : base(tieredPackageConfig) { } +#pragma warning restore CS8618 public TieredPackageConfig(IReadOnlyDictionary rawData) { @@ -518,8 +528,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 +537,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,10 +582,11 @@ public override void Validate() public TieredPackageConfigTier() { } - public TieredPackageConfigTier( - global::Orb.Models.Subscriptions.TieredPackageConfigTier tieredPackageConfigTier - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredPackageConfigTier(TieredPackageConfigTier tieredPackageConfigTier) : base(tieredPackageConfigTier) { } +#pragma warning restore CS8618 public TieredPackageConfigTier(IReadOnlyDictionary rawData) { @@ -597,8 +601,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 +610,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))] @@ -803,10 +806,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() { @@ -814,7 +817,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 b279882c4..ed5a352d9 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" ); } @@ -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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionTieredPackageWithMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionTieredPackageWithMinimumPrice( NewSubscriptionTieredPackageWithMinimumPrice newSubscriptionTieredPackageWithMinimumPrice ) : base(newSubscriptionTieredPackageWithMinimumPrice) { } +#pragma warning restore CS8618 public NewSubscriptionTieredPackageWithMinimumPrice( IReadOnlyDictionary rawData @@ -454,8 +471,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 +491,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) + ); } } @@ -503,10 +521,13 @@ public override void Validate() public TieredPackageWithMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredPackageWithMinimumConfig( - global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfig tieredPackageWithMinimumConfig + TieredPackageWithMinimumConfig tieredPackageWithMinimumConfig ) : base(tieredPackageWithMinimumConfig) { } +#pragma warning restore CS8618 public TieredPackageWithMinimumConfig(IReadOnlyDictionary rawData) { @@ -521,8 +542,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 +551,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 +564,8 @@ IReadOnlyDictionary rawData /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfigTier, - global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfigTierFromRaw + TieredPackageWithMinimumConfigTier, + TieredPackageWithMinimumConfigTierFromRaw >) )] public sealed record class TieredPackageWithMinimumConfigTier : JsonModel @@ -590,10 +610,13 @@ public override void Validate() public TieredPackageWithMinimumConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredPackageWithMinimumConfigTier( - global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfigTier tieredPackageWithMinimumConfigTier + TieredPackageWithMinimumConfigTier tieredPackageWithMinimumConfigTier ) : base(tieredPackageWithMinimumConfigTier) { } +#pragma warning restore CS8618 public TieredPackageWithMinimumConfigTier(IReadOnlyDictionary rawData) { @@ -608,8 +631,8 @@ public TieredPackageWithMinimumConfigTier(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.TieredPackageWithMinimumConfigTier FromRawUnchecked( + /// + public static TieredPackageWithMinimumConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -617,16 +640,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))] @@ -819,10 +838,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() { @@ -830,7 +849,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 d3dbefc1d..6e9a3be7b 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,14 +305,18 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionTieredPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionTieredPrice(NewSubscriptionTieredPrice newSubscriptionTieredPrice) : base(newSubscriptionTieredPrice) { } +#pragma warning restore CS8618 public NewSubscriptionTieredPrice(IReadOnlyDictionary rawData) { @@ -624,10 +641,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() { @@ -635,7 +652,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 9cfb82003..a391fac9a 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" ); } @@ -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,16 +311,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionTieredWithMinimumPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionTieredWithMinimumPrice( NewSubscriptionTieredWithMinimumPrice newSubscriptionTieredWithMinimumPrice ) : base(newSubscriptionTieredWithMinimumPrice) { } +#pragma warning restore CS8618 public NewSubscriptionTieredWithMinimumPrice(IReadOnlyDictionary rawData) { @@ -450,32 +467,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,10 +547,11 @@ public override void Validate() public TieredWithMinimumConfig() { } - public TieredWithMinimumConfig( - global::Orb.Models.Subscriptions.TieredWithMinimumConfig tieredWithMinimumConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumConfig(TieredWithMinimumConfig tieredWithMinimumConfig) : base(tieredWithMinimumConfig) { } +#pragma warning restore CS8618 public TieredWithMinimumConfig(IReadOnlyDictionary rawData) { @@ -552,8 +566,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 +575,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,10 +641,11 @@ public override void Validate() public TieredWithMinimumConfigTier() { } - public TieredWithMinimumConfigTier( - global::Orb.Models.Subscriptions.TieredWithMinimumConfigTier tieredWithMinimumConfigTier - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimumConfigTier(TieredWithMinimumConfigTier tieredWithMinimumConfigTier) : base(tieredWithMinimumConfigTier) { } +#pragma warning restore CS8618 public TieredWithMinimumConfigTier(IReadOnlyDictionary rawData) { @@ -651,8 +660,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 +669,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))] @@ -857,10 +865,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() { @@ -868,7 +876,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 5d518a9cb..6678ba296 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,14 +305,18 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionUnitPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionUnitPrice(NewSubscriptionUnitPrice newSubscriptionUnitPrice) : base(newSubscriptionUnitPrice) { } +#pragma warning restore CS8618 public NewSubscriptionUnitPrice(IReadOnlyDictionary rawData) { @@ -624,10 +641,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() { @@ -635,7 +652,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 76992d4a8..313ddbaea 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); } } @@ -243,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 @@ -297,16 +308,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionUnitWithPercentPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionUnitWithPercentPrice( NewSubscriptionUnitWithPercentPrice newSubscriptionUnitWithPercentPrice ) : base(newSubscriptionUnitWithPercentPrice) { } +#pragma warning restore CS8618 public NewSubscriptionUnitWithPercentPrice(IReadOnlyDictionary rawData) { @@ -446,12 +461,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,10 +499,11 @@ public override void Validate() public UnitWithPercentConfig() { } - public UnitWithPercentConfig( - global::Orb.Models.Subscriptions.UnitWithPercentConfig unitWithPercentConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithPercentConfig(UnitWithPercentConfig unitWithPercentConfig) : base(unitWithPercentConfig) { } +#pragma warning restore CS8618 public UnitWithPercentConfig(IReadOnlyDictionary rawData) { @@ -507,8 +518,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 +527,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))] @@ -713,10 +723,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() { @@ -724,7 +734,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 2a11c3c49..cbd5aa1d0 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" ); } @@ -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,16 +310,20 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } public NewSubscriptionUnitWithProrationPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSubscriptionUnitWithProrationPrice( NewSubscriptionUnitWithProrationPrice newSubscriptionUnitWithProrationPrice ) : base(newSubscriptionUnitWithProrationPrice) { } +#pragma warning restore CS8618 public NewSubscriptionUnitWithProrationPrice(IReadOnlyDictionary rawData) { @@ -449,12 +466,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,10 +490,11 @@ public override void Validate() public UnitWithProrationConfig() { } - public UnitWithProrationConfig( - global::Orb.Models.Subscriptions.UnitWithProrationConfig unitWithProrationConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithProrationConfig(UnitWithProrationConfig unitWithProrationConfig) : base(unitWithProrationConfig) { } +#pragma warning restore CS8618 public UnitWithProrationConfig(IReadOnlyDictionary rawData) { @@ -496,8 +509,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 +525,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))] @@ -709,10 +721,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() { @@ -720,7 +732,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 d98cab13e..c1b27d643 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" @@ -798,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() { @@ -809,7 +812,21 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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/SubscriptionCancelParams.cs b/src/Orb/Models/Subscriptions/SubscriptionCancelParams.cs index 7308e5a0d..f67dca64f 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +231,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 8313b8006..79fb6c016 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,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +839,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] @@ -812,14 +852,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); } } @@ -877,8 +915,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) { @@ -900,7 +941,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 +1240,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,10 +1275,10 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Subscriptions.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() { @@ -1253,12 +1286,28 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + 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 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 +1432,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 ) { @@ -1477,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. @@ -1508,12 +1579,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); } } @@ -1557,6 +1628,7 @@ public override void Validate() _ = this.EndDate; _ = this.ExternalPriceID; _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; _ = this.MinimumAmount; _ = this.PlanPhaseOrder; this.Price?.Validate(); @@ -1566,8 +1638,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) { @@ -1599,7 +1674,7 @@ public AddPrice FromRawUnchecked(IReadOnlyDictionary rawDat /// /// New subscription price request body params. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.PriceConverter))] +[JsonConverter(typeof(PriceConverter))] public record class Price : ModelBase { public object? Value { get; } = null; @@ -1650,7 +1725,6 @@ public string ItemID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ItemID, newSubscriptionCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, newSubscriptionMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -1691,7 +1765,6 @@ public string Name newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Name, newSubscriptionCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, newSubscriptionMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -1732,7 +1805,6 @@ public string? BillableMetricID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newSubscriptionCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, newSubscriptionMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -1773,7 +1845,6 @@ public bool? BilledInAdvance newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newSubscriptionCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -1814,7 +1885,6 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -1855,7 +1925,6 @@ public double? ConversionRate newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newSubscriptionCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, newSubscriptionMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -1896,7 +1965,6 @@ public string? Currency newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Currency, newSubscriptionCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, newSubscriptionMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -1939,7 +2007,6 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration x.DimensionalPriceConfiguration, newSubscriptionCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -1980,7 +2047,6 @@ public string? ExternalPriceID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newSubscriptionCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -2021,7 +2087,6 @@ public double? FixedPriceQuantity newSubscriptionScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newSubscriptionCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -2062,7 +2127,6 @@ public string? InvoiceGroupingKey newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -2104,7 +2168,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 @@ -2112,6 +2175,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 @@ -2145,7 +2248,6 @@ public string? ReferenceID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, newSubscriptionMinimumComposite: (x) => x.ReferenceID, percent: (x) => x.ReferenceID, eventOutput: (x) => x.ReferenceID @@ -2171,10 +2273,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 +2339,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 +2375,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 +2423,7 @@ public Price(NewSubscriptionCumulativeGroupedBulkPrice value, JsonElement? eleme this._element = element; } - public Price( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public Price(global::Orb.Models.Subscriptions.Minimum value, JsonElement? element = null) + public Price(CumulativeGroupedAllocation value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -2351,13 +2435,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 +2519,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 +2770,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 +2906,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 +3067,24 @@ public bool TryPickNewSubscriptionCumulativeGroupedBulk( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `global::Orb.Models.Subscriptions.CumulativeGroupedAllocation` + /// // `value` is of type `CumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out global::Orb.Models.Subscriptions.CumulativeGroupedAllocation? value - ) - { - value = this.Value as global::Orb.Models.Subscriptions.CumulativeGroupedAllocation; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Subscriptions.Minimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] out global::Orb.Models.Subscriptions.Minimum? value + [NotNullWhen(true)] out CumulativeGroupedAllocation? value ) { - value = this.Value as global::Orb.Models.Subscriptions.Minimum; + value = this.Value as CumulativeGroupedAllocation; return value != null; } @@ -3056,47 +3113,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 +3170,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 +3181,23 @@ public bool TryPickEventOutput( /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, /// (NewSubscriptionUnitWithPercentPrice value) => {...}, /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.TieredWithProration value) => {...}, + /// (TieredWithProration value) => {...}, /// (NewSubscriptionUnitWithProrationPrice value) => {...}, /// (NewSubscriptionGroupedAllocationPrice value) => {...}, /// (NewSubscriptionBulkWithProrationPrice value) => {...}, /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Subscriptions.Minimum value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Subscriptions.Percent value) => {...}, - /// (global::Orb.Models.Subscriptions.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -3154,7 +3206,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 +3217,23 @@ public void Switch( System::Action newSubscriptionPackageWithAllocation, System::Action newSubscriptionUnitWithPercent, System::Action newSubscriptionMatrixWithAllocation, - System::Action tieredWithProration, + System::Action tieredWithProration, System::Action newSubscriptionUnitWithProration, System::Action newSubscriptionGroupedAllocation, System::Action newSubscriptionBulkWithProration, System::Action newSubscriptionGroupedWithProratedMinimum, System::Action newSubscriptionGroupedWithMeteredMinimum, - System::Action groupedWithMinMaxThresholds, + System::Action groupedWithMinMaxThresholds, System::Action newSubscriptionMatrixWithDisplayName, System::Action newSubscriptionGroupedTieredPackage, System::Action newSubscriptionMaxGroupTieredPackage, System::Action newSubscriptionScalableMatrixWithUnitPricing, System::Action newSubscriptionScalableMatrixWithTieredPricing, System::Action newSubscriptionCumulativeGroupedBulk, - System::Action cumulativeGroupedAllocation, - System::Action minimum, + System::Action cumulativeGroupedAllocation, System::Action newSubscriptionMinimumComposite, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -3196,7 +3247,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 +3280,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 +3298,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 +3319,16 @@ public void Switch( case NewSubscriptionCumulativeGroupedBulkPrice value: newSubscriptionCumulativeGroupedBulk(value); break; - case global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value: + case CumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case global::Orb.Models.Subscriptions.Minimum value: - minimum(value); - break; case NewSubscriptionMinimumCompositePrice value: newSubscriptionMinimumComposite(value); break; - case global::Orb.Models.Subscriptions.Percent value: + case Percent value: percent(value); break; - case global::Orb.Models.Subscriptions.EventOutput value: + case EventOutput value: eventOutput(value); break; default: @@ -3306,7 +3354,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 +3365,23 @@ public void Switch( /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, /// (NewSubscriptionUnitWithPercentPrice value) => {...}, /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.TieredWithProration value) => {...}, + /// (TieredWithProration value) => {...}, /// (NewSubscriptionUnitWithProrationPrice value) => {...}, /// (NewSubscriptionGroupedAllocationPrice value) => {...}, /// (NewSubscriptionBulkWithProrationPrice value) => {...}, /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Subscriptions.Minimum value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Subscriptions.Percent value) => {...}, - /// (global::Orb.Models.Subscriptions.EventOutput value) => {...} + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -3343,7 +3390,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 +3413,7 @@ public T Match( NewSubscriptionMatrixWithAllocationPrice, T > newSubscriptionMatrixWithAllocation, - System::Func tieredWithProration, + System::Func tieredWithProration, System::Func newSubscriptionUnitWithProration, System::Func newSubscriptionGroupedAllocation, System::Func newSubscriptionBulkWithProration, @@ -3378,10 +3425,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 +3450,10 @@ public T Match( NewSubscriptionCumulativeGroupedBulkPrice, T > newSubscriptionCumulativeGroupedBulk, - System::Func< - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, + System::Func cumulativeGroupedAllocation, System::Func newSubscriptionMinimumComposite, - System::Func percent, - System::Func eventOutput + System::Func percent, + System::Func eventOutput ) { return this.Value switch @@ -3421,7 +3461,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 +3479,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 +3487,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 +3504,93 @@ public T Match( NewSubscriptionCumulativeGroupedBulkPrice value => newSubscriptionCumulativeGroupedBulk( value ), - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value => - cumulativeGroupedAllocation(value), - global::Orb.Models.Subscriptions.Minimum value => minimum(value), + CumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), - global::Orb.Models.Subscriptions.Percent value => percent(value), - global::Orb.Models.Subscriptions.EventOutput value => eventOutput(value), + Percent value => percent(value), + EventOutput value => eventOutput(value), _ => throw new OrbInvalidDataException("Data did not match any variant of Price"), }; } - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionUnitPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionUnitPrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionTieredPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionBulkPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionBulkPrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.BulkWithFilters value - ) => new(value); + public static implicit operator Price(BulkWithFilters value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionPackagePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionMatrixPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionMatrixPrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionThresholdTotalAmountPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionThresholdTotalAmountPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionTieredWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionTieredWithMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedTieredPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionTieredPackageWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionTieredPackageWithMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionPackageWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionPackageWithAllocationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionUnitWithPercentPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionUnitWithPercentPrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionMatrixWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionMatrixWithAllocationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.TieredWithProration value - ) => new(value); + public static implicit operator Price(TieredWithProration value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionUnitWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionUnitWithProrationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedAllocationPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedAllocationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionBulkWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionBulkWithProrationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedWithProratedMinimumPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedWithProratedMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedWithMeteredMinimumPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedWithMeteredMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds value - ) => new(value); + public static implicit operator Price(GroupedWithMinMaxThresholds value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionMatrixWithDisplayNamePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionMatrixWithDisplayNamePrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedTieredPackagePrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionMaxGroupTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionMaxGroupTieredPackagePrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( + public static implicit operator Price( NewSubscriptionScalableMatrixWithUnitPricingPrice value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( + public static implicit operator Price( NewSubscriptionScalableMatrixWithTieredPricingPrice value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionCumulativeGroupedBulkPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value - ) => new(value); + public static implicit operator Price(NewSubscriptionCumulativeGroupedBulkPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.Minimum value - ) => new(value); + public static implicit operator Price(CumulativeGroupedAllocation value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionMinimumCompositePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionMinimumCompositePrice value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.Percent value - ) => new(value); + public static implicit operator Price(Percent value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.EventOutput value - ) => new(value); + public static implicit operator Price(EventOutput value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -3659,17 +3646,16 @@ public override void Validate() (newSubscriptionCumulativeGroupedBulk) => newSubscriptionCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() ); } - public virtual bool Equals(global::Orb.Models.Subscriptions.Price? other) - { - 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() { @@ -3677,12 +3663,54 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 +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 +3799,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -4022,11 +4049,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -4160,11 +4186,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -4321,34 +4346,10 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -4390,11 +4391,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -4413,11 +4410,7 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { deserialized.Validate(); @@ -4434,40 +4427,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 +4457,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 +4565,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); } } @@ -4682,8 +4660,21 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/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 @@ -4743,6 +4734,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -4752,8 +4744,11 @@ public BulkWithFilters() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public BulkWithFilters(global::Orb.Models.Subscriptions.BulkWithFilters bulkWithFilters) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithFilters(BulkWithFilters bulkWithFilters) : base(bulkWithFilters) { } +#pragma warning restore CS8618 public BulkWithFilters(IReadOnlyDictionary rawData) { @@ -4770,49 +4765,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 +4807,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,10 +4838,11 @@ public override void Validate() public BulkWithFiltersConfig() { } - public BulkWithFiltersConfig( - global::Orb.Models.Subscriptions.BulkWithFiltersConfig bulkWithFiltersConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithFiltersConfig(BulkWithFiltersConfig bulkWithFiltersConfig) : base(bulkWithFiltersConfig) { } +#pragma warning restore CS8618 public BulkWithFiltersConfig(IReadOnlyDictionary rawData) { @@ -4873,8 +4857,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 +4866,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,8 +4915,11 @@ public override void Validate() public Filter() { } - public Filter(global::Orb.Models.Subscriptions.Filter filter) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Filter(Filter filter) : base(filter) { } +#pragma warning restore CS8618 public Filter(IReadOnlyDictionary rawData) { @@ -4953,32 +4934,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,8 +4989,11 @@ public override void Validate() public Tier() { } - public Tier(global::Orb.Models.Subscriptions.Tier tier) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Tier(Tier tier) : base(tier) { } +#pragma warning restore CS8618 public Tier(IReadOnlyDictionary rawData) { @@ -5032,10 +5008,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 +5022,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 +5043,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 +5053,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 +5084,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 +5237,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,10 +5264,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Subscriptions.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() { @@ -5308,13 +5275,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -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 +5358,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 +5373,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 +5433,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 +5504,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" ); } @@ -5629,6 +5600,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 @@ -5691,6 +5675,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -5700,10 +5685,11 @@ public TieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public TieredWithProration( - global::Orb.Models.Subscriptions.TieredWithProration tieredWithProration - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProration(TieredWithProration tieredWithProration) : base(tieredWithProration) { } +#pragma warning restore CS8618 public TieredWithProration(IReadOnlyDictionary rawData) { @@ -5720,8 +5706,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 +5715,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 +5736,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 +5746,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 +5766,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 +5785,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 +5793,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,10 +5822,11 @@ public override void Validate() public TieredWithProrationConfig() { } - public TieredWithProrationConfig( - global::Orb.Models.Subscriptions.TieredWithProrationConfig tieredWithProrationConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) : base(tieredWithProrationConfig) { } +#pragma warning restore CS8618 public TieredWithProrationConfig(IReadOnlyDictionary rawData) { @@ -5861,8 +5841,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 +5850,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 { @@ -5934,10 +5908,13 @@ public override void Validate() public TieredWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationConfigTier( - global::Orb.Models.Subscriptions.TieredWithProrationConfigTier tieredWithProrationConfigTier + TieredWithProrationConfigTier tieredWithProrationConfigTier ) : base(tieredWithProrationConfigTier) { } +#pragma warning restore CS8618 public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) { @@ -5952,8 +5929,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 +5938,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 +6105,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,12 +6134,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Subscriptions.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() { @@ -6173,13 +6145,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } 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 +6229,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 +6245,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 +6267,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 +6377,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" ); } @@ -6496,6 +6473,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 +6548,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -6567,10 +6558,11 @@ public GroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { @@ -6587,8 +6579,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 +6588,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 +6611,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 +6621,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 +6641,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 +6661,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfigFromRaw + GroupedWithMinMaxThresholdsConfig, + GroupedWithMinMaxThresholdsConfigFromRaw >) )] public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel @@ -6763,10 +6730,13 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { @@ -6781,8 +6751,8 @@ public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6790,21 +6760,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 +6927,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,12 +6956,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Subscriptions.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() { @@ -7005,13 +6967,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } 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 +7051,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 +7067,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 +7089,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 +7199,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" ); } @@ -7328,6 +7295,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 @@ -7390,6 +7370,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -7399,10 +7380,11 @@ public CumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) { @@ -7419,8 +7401,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 +7410,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 +7433,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 +7443,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 +7463,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 +7483,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig, - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfigFromRaw + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw >) )] public sealed record class CumulativeGroupedAllocationConfig : JsonModel @@ -7595,10 +7552,13 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocationConfig( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { @@ -7613,8 +7573,8 @@ public CumulativeGroupedAllocationConfig(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7622,21 +7582,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 +7749,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,12 +7778,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Subscriptions.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() { @@ -7837,13 +7789,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } 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 +7873,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig( - element - ); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -7925,23 +7888,18 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.Minimum, - global::Orb.Models.Subscriptions.MinimumFromRaw - >) -)] -public sealed record class Minimum : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Percent : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -7960,44 +7918,42 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// The pricing model type /// - public required global::Orb.Models.Subscriptions.MinimumConfig MinimumConfig + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("model_type", value); } } /// - /// The pricing model type + /// The name of the price. /// - public JsonElement ModelType + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("model_type", value); } + init { this._rawData.Set("name", value); } } /// - /// The name of the price. + /// Configuration for percent pricing /// - public required string Name + public required PercentConfig PercentConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNotNullClass("percent_config"); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("percent_config", value); } } /// @@ -8059,12 +8015,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" ); } @@ -8155,6 +8111,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 @@ -8195,12 +8164,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(); @@ -8212,55 +8181,56 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Minimum() + public Percent() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public Minimum(global::Orb.Models.Subscriptions.Minimum minimum) - : base(minimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Percent(Percent percent) + : base(percent) { } +#pragma warning restore CS8618 - public Minimum(IReadOnlyDictionary rawData) + public Percent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + Percent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.Minimum.FromRawUnchecked(rawData); + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(MinimumCadenceConverter))] -public enum MinimumCadence +[JsonConverter(typeof(PercentCadenceConverter))] +public enum PercentCadence { Annual, SemiAnnual, @@ -8270,9 +8240,9 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter : JsonConverter +sealed class PercentCadenceConverter : JsonConverter { - public override MinimumCadence Read( + public override PercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8280,19 +8250,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => MinimumCadence.Annual, - "semi_annual" => MinimumCadence.SemiAnnual, - "monthly" => MinimumCadence.Monthly, - "quarterly" => MinimumCadence.Quarterly, - "one_time" => MinimumCadence.OneTime, - "custom" => MinimumCadence.Custom, - _ => (MinimumCadence)(-1), + "annual" => PercentCadence.Annual, + "semi_annual" => PercentCadence.SemiAnnual, + "monthly" => PercentCadence.Monthly, + "quarterly" => PercentCadence.Quarterly, + "one_time" => PercentCadence.OneTime, + "custom" => PercentCadence.Custom, + _ => (PercentCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - MinimumCadence value, + PercentCadence value, JsonSerializerOptions options ) { @@ -8300,12 +8270,12 @@ JsonSerializerOptions options writer, value switch { - MinimumCadence.Annual => "annual", - MinimumCadence.SemiAnnual => "semi_annual", - MinimumCadence.Monthly => "monthly", - MinimumCadence.Quarterly => "quarterly", - MinimumCadence.OneTime => "one_time", - MinimumCadence.Custom => "custom", + PercentCadence.Annual => "annual", + PercentCadence.SemiAnnual => "semi_annual", + PercentCadence.Monthly => "monthly", + PercentCadence.Quarterly => "quarterly", + PercentCadence.OneTime => "one_time", + PercentCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -8316,101 +8286,74 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for percent pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.MinimumConfig, - global::Orb.Models.Subscriptions.MinimumConfigFromRaw - >) -)] -public sealed record class MinimumConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PercentConfig : JsonModel { /// - /// The minimum amount to apply - /// - public required string MinimumAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); - } - init { this._rawData.Set("minimum_amount", value); } - } - - /// - /// If true, subtotals from this price are prorated based on the service period + /// What percent of the component subtotals to charge /// - public bool? Prorated + public required double Percent { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); - } - init - { - if (value == null) - { - return; - } - - this._rawData.Set("prorated", value); + return this._rawData.GetNotNullStruct("percent"); } + init { this._rawData.Set("percent", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.Percent; } - public MinimumConfig() { } + public PercentConfig() { } - public MinimumConfig(global::Orb.Models.Subscriptions.MinimumConfig minimumConfig) - : base(minimumConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PercentConfig(PercentConfig percentConfig) + : base(percentConfig) { } +#pragma warning restore CS8618 - public MinimumConfig(IReadOnlyDictionary rawData) + public PercentConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + PercentConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) + public PercentConfig(double percent) : this() { - this.MinimumAmount = minimumAmount; + this.Percent = percent; } } -class MinimumConfigFromRaw : IFromRawJson +class PercentConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.MinimumConfig.FromRawUnchecked(rawData); + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(PercentConversionRateConfigConverter))] +public record class PercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8427,7 +8370,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8436,7 +8379,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8445,7 +8388,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public PercentConversionRateConfig(JsonElement element) { this._element = element; } @@ -8527,7 +8470,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ); } } @@ -8563,16 +8506,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ), }; } - public static implicit operator MinimumConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator MinimumConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8591,16 +8534,16 @@ 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) - { - 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() { @@ -8608,12 +8551,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class MinimumConversionRateConfigConverter : JsonConverter +sealed class PercentConversionRateConfigConverter : JsonConverter { - public override MinimumConversionRateConfig? Read( + public override PercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8678,14 +8634,14 @@ JsonSerializerOptions options } default: { - return new MinimumConversionRateConfig(element); + return new PercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MinimumConversionRateConfig value, + PercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -8693,29 +8649,35 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.Percent, - global::Orb.Models.Subscriptions.PercentFromRaw - >) -)] -public sealed record class Percent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class EventOutput : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } + /// + /// Configuration for event_output pricing + /// + public required EventOutputConfig EventOutputConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("event_output_config"); + } + init { this._rawData.Set("event_output_config", value); } + } + /// /// The id of the item the price will be associated with. /// @@ -8755,21 +8717,6 @@ public required string Name init { this._rawData.Set("name", value); } } - /// - /// Configuration for percent pricing - /// - public required global::Orb.Models.Subscriptions.PercentConfig PercentConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); - } - init { this._rawData.Set("percent_config", value); } - } - /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -8829,12 +8776,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Subscriptions.PercentConversionRateConfig? ConversionRateConfig + public EventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8925,6 +8872,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 @@ -8964,13 +8924,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(); @@ -8982,55 +8947,56 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Percent() + public EventOutput() { - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public Percent(global::Orb.Models.Subscriptions.Percent percent) - : base(percent) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutput(EventOutput eventOutput) + : base(eventOutput) { } +#pragma warning restore CS8618 - public Percent(IReadOnlyDictionary rawData) + public EventOutput(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Percent(FrozenDictionary rawData) + EventOutput(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PercentFromRaw : IFromRawJson +class EventOutputFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.Percent.FromRawUnchecked(rawData); + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(EventOutputCadenceConverter))] +public enum EventOutputCadence { Annual, SemiAnnual, @@ -9040,10 +9006,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter - : JsonConverter +sealed class EventOutputCadenceConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.PercentCadence Read( + public override EventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9051,19 +9016,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Subscriptions.PercentCadence.Annual, - "semi_annual" => global::Orb.Models.Subscriptions.PercentCadence.SemiAnnual, - "monthly" => global::Orb.Models.Subscriptions.PercentCadence.Monthly, - "quarterly" => global::Orb.Models.Subscriptions.PercentCadence.Quarterly, - "one_time" => global::Orb.Models.Subscriptions.PercentCadence.OneTime, - "custom" => global::Orb.Models.Subscriptions.PercentCadence.Custom, - _ => (global::Orb.Models.Subscriptions.PercentCadence)(-1), + "annual" => EventOutputCadence.Annual, + "semi_annual" => EventOutputCadence.SemiAnnual, + "monthly" => EventOutputCadence.Monthly, + "quarterly" => EventOutputCadence.Quarterly, + "one_time" => EventOutputCadence.OneTime, + "custom" => EventOutputCadence.Custom, + _ => (EventOutputCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.PercentCadence value, + EventOutputCadence value, JsonSerializerOptions options ) { @@ -9071,12 +9036,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Subscriptions.PercentCadence.Annual => "annual", - global::Orb.Models.Subscriptions.PercentCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Subscriptions.PercentCadence.Monthly => "monthly", - global::Orb.Models.Subscriptions.PercentCadence.Quarterly => "quarterly", - global::Orb.Models.Subscriptions.PercentCadence.OneTime => "one_time", - global::Orb.Models.Subscriptions.PercentCadence.Custom => "custom", + EventOutputCadence.Annual => "annual", + EventOutputCadence.SemiAnnual => "semi_annual", + EventOutputCadence.Monthly => "monthly", + EventOutputCadence.Quarterly => "quarterly", + EventOutputCadence.OneTime => "one_time", + EventOutputCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -9087,55 +9052,84 @@ JsonSerializerOptions options } /// -/// Configuration for percent pricing +/// Configuration for event_output pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.PercentConfig, - global::Orb.Models.Subscriptions.PercentConfigFromRaw - >) -)] -public sealed record class PercentConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class EventOutputConfig : JsonModel { /// - /// What percent of the component subtotals to charge + /// The key in the event data to extract the unit rate from. /// - public required double Percent + public required string UnitRatingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); + return this._rawData.GetNotNullClass("unit_rating_key"); } - init { this._rawData.Set("percent", value); } + init { this._rawData.Set("unit_rating_key", value); } + } + + /// + /// If provided, this amount will be used as the unit rate when an event does + /// not have a value for the `unit_rating_key`. If not provided, events missing + /// a unit rate will be ignored. + /// + public string? DefaultUnitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("default_unit_rate"); + } + init { this._rawData.Set("default_unit_rate", value); } + } + + /// + /// An optional key in the event data to group by (e.g., event ID). All events + /// will also be grouped by their unit rate. + /// + public string? GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } } /// public override void Validate() { - _ = this.Percent; + _ = this.UnitRatingKey; + _ = this.DefaultUnitRate; + _ = this.GroupingKey; } - public PercentConfig() { } + public EventOutputConfig() { } - public PercentConfig(global::Orb.Models.Subscriptions.PercentConfig percentConfig) - : base(percentConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutputConfig(EventOutputConfig eventOutputConfig) + : base(eventOutputConfig) { } +#pragma warning restore CS8618 - public PercentConfig(IReadOnlyDictionary rawData) + public EventOutputConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PercentConfig(FrozenDictionary rawData) + EventOutputConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.PercentConfig FromRawUnchecked( + /// + public static EventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9143,23 +9137,22 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public PercentConfig(double percent) + public EventOutputConfig(string unitRatingKey) : this() { - this.Percent = percent; + this.UnitRatingKey = unitRatingKey; } } -class PercentConfigFromRaw : IFromRawJson +class EventOutputConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.PercentConfig.FromRawUnchecked(rawData); + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Subscriptions.PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] +public record class EventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -9176,7 +9169,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public EventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9185,7 +9178,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public EventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9194,7 +9187,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public EventOutputConversionRateConfig(JsonElement element) { this._element = element; } @@ -9276,7 +9269,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of EventOutputConversionRateConfig" ); } } @@ -9312,16 +9305,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of EventOutputConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Subscriptions.PercentConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.PercentConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -9340,16 +9333,16 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of EventOutputConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Subscriptions.PercentConversionRateConfig? other) - { - 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() { @@ -9357,13 +9350,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class PercentConversionRateConfigConverter - : JsonConverter +sealed class EventOutputConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.PercentConversionRateConfig? Read( + public override EventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9428,14 +9434,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.PercentConversionRateConfig(element); + return new EventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.PercentConversionRateConfig value, + EventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -9443,329 +9449,250 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.EventOutput, - global::Orb.Models.Subscriptions.EventOutputFromRaw - >) -)] -public sealed record class EventOutput : JsonModel +[System::Obsolete("deprecated")] +[JsonConverter(typeof(ExternalMarketplaceConverter))] +public enum ExternalMarketplace { - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum Cadence + Google, + Aws, + Azure, +} + +sealed class ExternalMarketplaceConverter : JsonConverter +{ + public override ExternalMarketplace Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - get + return JsonSerializer.Deserialize(ref reader, options) switch { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); - } - init { this._rawData.Set("cadence", value); } + "google" => ExternalMarketplace.Google, + "aws" => ExternalMarketplace.Aws, + "azure" => ExternalMarketplace.Azure, + _ => (ExternalMarketplace)(-1), + }; } - /// - /// Configuration for event_output pricing - /// - public required global::Orb.Models.Subscriptions.EventOutputConfig EventOutputConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "event_output_config" - ); - } - init { this._rawData.Set("event_output_config", value); } + 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 + ); } +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemoveAdjustment : JsonModel +{ /// - /// The id of the item the price will be associated with. + /// The id of the adjustment to remove on the subscription. /// - public required string ItemID + public required string AdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass("adjustment_id"); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("adjustment_id", value); } } - /// - /// The pricing model type - /// - public JsonElement ModelType + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } + _ = this.AdjustmentID; } - /// - /// The name of the price. - /// - public required string Name + public RemoveAdjustment() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public RemoveAdjustment(RemoveAdjustment removeAdjustment) + : base(removeAdjustment) { } +#pragma warning restore CS8618 + + public RemoveAdjustment(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } + this._rawData = new(rawData); } - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemoveAdjustment(FrozenDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance + /// + public static RemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration + [SetsRequiredMembers] + public RemoveAdjustment(string adjustmentID) + : this() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } + this.AdjustmentID = adjustmentID; } +} + +class RemoveAdjustmentFromRaw : IFromRawJson +{ + /// + public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + RemoveAdjustment.FromRawUnchecked(rawData); +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemovePrice : JsonModel +{ /// - /// The per unit conversion rate of the price currency to the invoicing currency. + /// The external price id of the price to remove on the subscription. /// - public double? ConversionRate + public string? ExternalPriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); + return this._rawData.GetNullableClass("external_price_id"); } - init { this._rawData.Set("conversion_rate", value); } + init { this._rawData.Set("external_price_id", value); } } /// - /// The configuration for the rate of the price currency to the invoicing currency. + /// The id of the price to remove on the subscription. /// - public global::Orb.Models.Subscriptions.EventOutputConversionRateConfig? ConversionRateConfig + public string? PriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); + return this._rawData.GetNullableClass("price_id"); } - init { this._rawData.Set("conversion_rate_config", value); } + init { this._rawData.Set("price_id", value); } } - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); - } - init { this._rawData.Set("currency", value); } + _ = this.ExternalPriceID; + _ = this.PriceID; } - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + public RemovePrice() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public RemovePrice(RemovePrice removePrice) + : base(removePrice) { } +#pragma warning restore CS8618 + + public RemovePrice(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } + this._rawData = new(rawData); } - /// - /// An alias for the price. - /// - public string? ExternalPriceID +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemovePrice(FrozenDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity + /// + public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} + +class RemovePriceFromRaw : IFromRawJson +{ + /// + public RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + RemovePrice.FromRawUnchecked(rawData); +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ReplaceAdjustment : JsonModel +{ /// - /// The property used to group this price on an invoice + /// The definition of a new adjustment to create and add to the subscription. /// - public string? InvoiceGroupingKey + public required ReplaceAdjustmentAdjustment Adjustment { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); + return this._rawData.GetNotNullClass("adjustment"); } - init { this._rawData.Set("invoice_grouping_key", value); } + init { this._rawData.Set("adjustment", value); } } /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. + /// The id of the adjustment on the plan to replace in the subscription. /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + public required string ReplacesAdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); + return this._rawData.GetNotNullClass("replaces_adjustment_id"); } - init { this._rawData.Set("invoicing_cycle_configuration", value); } + init { this._rawData.Set("replaces_adjustment_id", value); } } - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); - } - init { this._rawData.Set("reference_id", value); } - } - - /// - public override void Validate() - { - this.Cadence.Validate(); - this.EventOutputConfig.Validate(); - _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("event_output") - ) - ) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - _ = this.Currency; - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - _ = this.ReferenceID; + this.Adjustment.Validate(); + _ = this.ReplacesAdjustmentID; } - public EventOutput() - { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); - } + public ReplaceAdjustment() { } - public EventOutput(global::Orb.Models.Subscriptions.EventOutput eventOutput) - : base(eventOutput) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) + : base(replaceAdjustment) { } +#pragma warning restore CS8618 - public EventOutput(IReadOnlyDictionary rawData) + public ReplaceAdjustment(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("event_output"); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) + ReplaceAdjustment(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.EventOutput FromRawUnchecked( + /// + public static ReplaceAdjustment FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9773,257 +9700,199 @@ IReadOnlyDictionary rawData } } -class EventOutputFromRaw : IFromRawJson +class ReplaceAdjustmentFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.EventOutput.FromRawUnchecked(rawData); + public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplaceAdjustment.FromRawUnchecked(rawData); } /// -/// The cadence to bill for this price on. +/// The definition of a new adjustment to create and add to the subscription. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.EventOutputCadenceConverter))] -public enum EventOutputCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class EventOutputCadenceConverter - : JsonConverter +[JsonConverter(typeof(ReplaceAdjustmentAdjustmentConverter))] +public record class ReplaceAdjustmentAdjustment : ModelBase { - public override global::Orb.Models.Subscriptions.EventOutputCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => global::Orb.Models.Subscriptions.EventOutputCadence.Annual, - "semi_annual" => global::Orb.Models.Subscriptions.EventOutputCadence.SemiAnnual, - "monthly" => global::Orb.Models.Subscriptions.EventOutputCadence.Monthly, - "quarterly" => global::Orb.Models.Subscriptions.EventOutputCadence.Quarterly, - "one_time" => global::Orb.Models.Subscriptions.EventOutputCadence.OneTime, - "custom" => global::Orb.Models.Subscriptions.EventOutputCadence.Custom, - _ => (global::Orb.Models.Subscriptions.EventOutputCadence)(-1), - }; - } + public object? Value { get; } = null; - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.EventOutputCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - global::Orb.Models.Subscriptions.EventOutputCadence.Annual => "annual", - global::Orb.Models.Subscriptions.EventOutputCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Subscriptions.EventOutputCadence.Monthly => "monthly", - global::Orb.Models.Subscriptions.EventOutputCadence.Quarterly => "quarterly", - global::Orb.Models.Subscriptions.EventOutputCadence.OneTime => "one_time", - global::Orb.Models.Subscriptions.EventOutputCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} + JsonElement? _element = null; -/// -/// Configuration for event_output pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.EventOutputConfig, - global::Orb.Models.Subscriptions.EventOutputConfigFromRaw - >) -)] -public sealed record class EventOutputConfig : JsonModel -{ - /// - /// The key in the event data to extract the unit rate from. - /// - public required string UnitRatingKey + public JsonElement Json { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rating_key"); + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); } - init { this._rawData.Set("unit_rating_key", value); } } - /// - /// If provided, this amount will be used as the unit rate when an event does - /// not have a value for the `unit_rating_key`. If not provided, events missing - /// a unit rate will be ignored. - /// - public string? DefaultUnitRate + public string? Currency { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("default_unit_rate"); + return Match( + newPercentageDiscount: (x) => x.Currency, + newUsageDiscount: (x) => x.Currency, + newAmountDiscount: (x) => x.Currency, + newMinimum: (x) => x.Currency, + newMaximum: (x) => x.Currency + ); } - init { this._rawData.Set("default_unit_rate", value); } } - /// - /// An optional key in the event data to group by (e.g., event ID). All events - /// will also be grouped by their unit rate. - /// - public string? GroupingKey + public bool? IsInvoiceLevel { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); + return Match( + newPercentageDiscount: (x) => x.IsInvoiceLevel, + newUsageDiscount: (x) => x.IsInvoiceLevel, + newAmountDiscount: (x) => x.IsInvoiceLevel, + newMinimum: (x) => x.IsInvoiceLevel, + newMaximum: (x) => x.IsInvoiceLevel + ); } - init { this._rawData.Set("grouping_key", value); } - } - - /// - public override void Validate() - { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; - _ = this.GroupingKey; - } - - public EventOutputConfig() { } - - public EventOutputConfig(global::Orb.Models.Subscriptions.EventOutputConfig eventOutputConfig) - : base(eventOutputConfig) { } - - public EventOutputConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - EventOutputConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) - : this() + public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) { - this.UnitRatingKey = unitRatingKey; + this.Value = value; + this._element = element; } -} - -class EventOutputConfigFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Subscriptions.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.EventOutputConfig.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(global::Orb.Models.Subscriptions.EventOutputConversionRateConfigConverter))] -public record class EventOutputConversionRateConfig : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - public JsonElement Json + 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; + } + + /// + /// Returns true and sets the 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; } @@ -10041,28 +9910,43 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// /// public void Switch( - System::Action unit, - System::Action tiered + System::Action newPercentageDiscount, + System::Action newUsageDiscount, + System::Action newAmountDiscount, + System::Action newMinimum, + System::Action newMaximum ) { switch (this.Value) { - case SharedUnitConversionRateConfig value: - unit(value); + case NewPercentageDiscount value: + newPercentageDiscount(value); break; - case SharedTieredConversionRateConfig value: - tiered(value); + case NewUsageDiscount value: + newUsageDiscount(value); + break; + case NewAmountDiscount value: + newAmountDiscount(value); + break; + case NewMinimum value: + newMinimum(value); + break; + case NewMaximum value: + newMaximum(value); break; default: throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of ReplaceAdjustmentAdjustment" ); } } @@ -10082,34 +9966,48 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// /// public T Match( - System::Func unit, - System::Func tiered + System::Func newPercentageDiscount, + System::Func newUsageDiscount, + System::Func newAmountDiscount, + System::Func newMinimum, + System::Func newMaximum ) { return this.Value switch { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), + NewPercentageDiscount value => newPercentageDiscount(value), + NewUsageDiscount value => newUsageDiscount(value), + NewAmountDiscount value => newAmountDiscount(value), + NewMinimum value => newMinimum(value), + NewMaximum value => newMaximum(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of ReplaceAdjustmentAdjustment" ), }; } - public static implicit operator global::Orb.Models.Subscriptions.EventOutputConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.EventOutputConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewUsageDiscount value) => + new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewAmountDiscount value) => + new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewMinimum value) => new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -10126,18 +10024,22 @@ public override void Validate() if (this.Value == null) { throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of ReplaceAdjustmentAdjustment" ); } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + this.Switch( + (newPercentageDiscount) => newPercentageDiscount.Validate(), + (newUsageDiscount) => newUsageDiscount.Validate(), + (newAmountDiscount) => newAmountDiscount.Validate(), + (newMinimum) => newMinimum.Validate(), + (newMaximum) => newMaximum.Validate() + ); } - public virtual bool Equals( - global::Orb.Models.Subscriptions.EventOutputConversionRateConfig? other - ) - { - 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() { @@ -10145,36 +10047,51 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + 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 EventOutputConversionRateConfigConverter - : JsonConverter +sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.EventOutputConversionRateConfig? Read( + public override ReplaceAdjustmentAdjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; + string? adjustmentType; try { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + adjustmentType = element.GetProperty("adjustment_type").GetString(); } catch { - conversionRateType = null; + adjustmentType = null; } - switch (conversionRateType) + switch (adjustmentType) { - case "unit": + case "percentage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -10192,11 +10109,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 ); @@ -10214,18 +10153,54 @@ JsonSerializerOptions options return new(element); } + case "minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } + + return new(element); + } + case "maximum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } + + return new(element); + } default: { - return new global::Orb.Models.Subscriptions.EventOutputConversionRateConfig( - element - ); + return new ReplaceAdjustmentAdjustment(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.EventOutputConversionRateConfig value, + ReplaceAdjustmentAdjustment value, JsonSerializerOptions options ) { @@ -10233,135 +10208,149 @@ JsonSerializerOptions options } } -[System::Obsolete("deprecated")] -[JsonConverter(typeof(ExternalMarketplaceConverter))] -public enum ExternalMarketplace +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ReplacePrice : JsonModel { - Google, - Aws, - Azure, -} - -sealed class ExternalMarketplaceConverter : JsonConverter -{ - 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), - }; + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("replaces_price_id"); + } + init { this._rawData.Set("replaces_price_id", value); } } - public override void Write( - Utf8JsonWriter writer, - ExternalMarketplace value, - JsonSerializerOptions options - ) + /// + /// The definition of a new allocation price to create and add to the subscription. + /// + public NewAllocationPrice? AllocationPrice { - 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 - ); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allocation_price"); + } + init { this._rawData.Set("allocation_price", value); } } -} -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemoveAdjustment : JsonModel -{ /// - /// The id of the adjustment to remove on the subscription. + /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for + /// the replacement price. /// - public required string AdjustmentID + [System::Obsolete("deprecated")] + public IReadOnlyList? Discounts { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment_id"); + return this._rawData.GetNullableStruct>("discounts"); + } + init + { + this._rawData.Set?>( + "discounts", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("adjustment_id", value); } } - /// - public override void Validate() + /// + /// The external price id of the price to add to the subscription. + /// + public string? ExternalPriceID { - _ = this.AdjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } } - public RemoveAdjustment() { } - - public RemoveAdjustment(RemoveAdjustment removeAdjustment) - : base(removeAdjustment) { } - - public RemoveAdjustment(IReadOnlyDictionary rawData) + /// + /// The new quantity of the price, if the price is a fixed price. + /// + public double? FixedPriceQuantity { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveAdjustment(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 RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values. + /// + public IReadOnlyDictionary? MetricParameterOverrides { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } } - [SetsRequiredMembers] - public RemoveAdjustment(string adjustmentID) - : this() + /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount + /// for the replacement price. + /// + [System::Obsolete("deprecated")] + public string? MinimumAmount { - this.AdjustmentID = adjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", 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. + /// New subscription price request body params. /// - public string? ExternalPriceID + public ReplacePricePrice? Price { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); + return this._rawData.GetNullableClass("price"); } - init { this._rawData.Set("external_price_id", value); } + init { this._rawData.Set("price", value); } } /// - /// The id of the price to remove on the subscription. + /// The id of the price to add to the subscription. /// public string? PriceID { @@ -10376,1641 +10365,940 @@ 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.MetricParameterOverrides; + _ = this.MinimumAmount; + this.Price?.Validate(); _ = this.PriceID; } - public RemovePrice() { } + public ReplacePrice() { } - public RemovePrice(RemovePrice removePrice) - : base(removePrice) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePrice(ReplacePrice replacePrice) + : base(replacePrice) { } +#pragma warning restore CS8618 - public RemovePrice(IReadOnlyDictionary rawData) + public ReplacePrice(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - RemovePrice(FrozenDictionary rawData) + ReplacePrice(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public ReplacePrice(string replacesPriceID) + : this() + { + this.ReplacesPriceID = replacesPriceID; + } } -class RemovePriceFromRaw : IFromRawJson +class ReplacePriceFromRaw : IFromRawJson { /// - public RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) => - RemovePrice.FromRawUnchecked(rawData); + public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplacePrice.FromRawUnchecked(rawData); } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class ReplaceAdjustment : JsonModel +/// +/// New subscription price request body params. +/// +[JsonConverter(typeof(ReplacePricePriceConverter))] +public record class ReplacePricePrice : ModelBase { - /// - /// The definition of a new adjustment to create and add to the subscription. - /// - public required ReplaceAdjustmentAdjustment Adjustment + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment"); + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); } - init { this._rawData.Set("adjustment", value); } } - /// - /// The id of the adjustment on the plan to replace in the subscription. - /// - public required string ReplacesAdjustmentID + public string ItemID { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); - } - init { this._rawData.Set("replaces_adjustment_id", value); } - } - - /// - public override void Validate() - { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; - } - - public ReplaceAdjustment() { } - - public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) - : base(replaceAdjustment) { } - - public ReplaceAdjustment(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplaceAdjustment(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + 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 + ); + } } -} - -class ReplaceAdjustmentFromRaw : IFromRawJson -{ - /// - public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => - ReplaceAdjustment.FromRawUnchecked(rawData); -} - -/// -/// The definition of a new adjustment to create and add to the subscription. -/// -[JsonConverter(typeof(ReplaceAdjustmentAdjustmentConverter))] -public record class ReplaceAdjustmentAdjustment : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - public JsonElement Json + public string Name { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions + return Match( + newSubscriptionUnit: (x) => x.Name, + newSubscriptionTiered: (x) => x.Name, + newSubscriptionBulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + newSubscriptionPackage: (x) => x.Name, + newSubscriptionMatrix: (x) => x.Name, + newSubscriptionThresholdTotalAmount: (x) => x.Name, + newSubscriptionTieredPackage: (x) => x.Name, + newSubscriptionTieredWithMinimum: (x) => x.Name, + newSubscriptionGroupedTiered: (x) => x.Name, + newSubscriptionTieredPackageWithMinimum: (x) => x.Name, + newSubscriptionPackageWithAllocation: (x) => x.Name, + newSubscriptionUnitWithPercent: (x) => x.Name, + newSubscriptionMatrixWithAllocation: (x) => x.Name, + tieredWithProration: (x) => x.Name, + newSubscriptionUnitWithProration: (x) => x.Name, + newSubscriptionGroupedAllocation: (x) => x.Name, + newSubscriptionBulkWithProration: (x) => x.Name, + newSubscriptionGroupedWithProratedMinimum: (x) => x.Name, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.Name, + groupedWithMinMaxThresholds: (x) => x.Name, + newSubscriptionMatrixWithDisplayName: (x) => x.Name, + newSubscriptionGroupedTieredPackage: (x) => x.Name, + newSubscriptionMaxGroupTieredPackage: (x) => x.Name, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Name, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Name, + newSubscriptionCumulativeGroupedBulk: (x) => x.Name, + cumulativeGroupedAllocation: (x) => x.Name, + newSubscriptionMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name ); } } - public string? Currency + public string? BillableMetricID { get { return Match( - newPercentageDiscount: (x) => x.Currency, - newUsageDiscount: (x) => x.Currency, - newAmountDiscount: (x) => x.Currency, - newMinimum: (x) => x.Currency, - newMaximum: (x) => x.Currency + newSubscriptionUnit: (x) => x.BillableMetricID, + newSubscriptionTiered: (x) => x.BillableMetricID, + newSubscriptionBulk: (x) => x.BillableMetricID, + bulkWithFilters: (x) => x.BillableMetricID, + newSubscriptionPackage: (x) => x.BillableMetricID, + newSubscriptionMatrix: (x) => x.BillableMetricID, + newSubscriptionThresholdTotalAmount: (x) => x.BillableMetricID, + newSubscriptionTieredPackage: (x) => x.BillableMetricID, + newSubscriptionTieredWithMinimum: (x) => x.BillableMetricID, + newSubscriptionGroupedTiered: (x) => x.BillableMetricID, + newSubscriptionTieredPackageWithMinimum: (x) => x.BillableMetricID, + newSubscriptionPackageWithAllocation: (x) => x.BillableMetricID, + newSubscriptionUnitWithPercent: (x) => x.BillableMetricID, + newSubscriptionMatrixWithAllocation: (x) => x.BillableMetricID, + tieredWithProration: (x) => x.BillableMetricID, + newSubscriptionUnitWithProration: (x) => x.BillableMetricID, + newSubscriptionGroupedAllocation: (x) => x.BillableMetricID, + newSubscriptionBulkWithProration: (x) => x.BillableMetricID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BillableMetricID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillableMetricID, + groupedWithMinMaxThresholds: (x) => x.BillableMetricID, + newSubscriptionMatrixWithDisplayName: (x) => x.BillableMetricID, + newSubscriptionGroupedTieredPackage: (x) => x.BillableMetricID, + newSubscriptionMaxGroupTieredPackage: (x) => x.BillableMetricID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, + newSubscriptionCumulativeGroupedBulk: (x) => x.BillableMetricID, + cumulativeGroupedAllocation: (x) => x.BillableMetricID, + newSubscriptionMinimumComposite: (x) => x.BillableMetricID, + percent: (x) => x.BillableMetricID, + eventOutput: (x) => x.BillableMetricID ); } } - public bool? IsInvoiceLevel + public bool? BilledInAdvance { get { return Match( - newPercentageDiscount: (x) => x.IsInvoiceLevel, - newUsageDiscount: (x) => x.IsInvoiceLevel, - newAmountDiscount: (x) => x.IsInvoiceLevel, - newMinimum: (x) => x.IsInvoiceLevel, - newMaximum: (x) => x.IsInvoiceLevel + newSubscriptionUnit: (x) => x.BilledInAdvance, + newSubscriptionTiered: (x) => x.BilledInAdvance, + newSubscriptionBulk: (x) => x.BilledInAdvance, + bulkWithFilters: (x) => x.BilledInAdvance, + newSubscriptionPackage: (x) => x.BilledInAdvance, + newSubscriptionMatrix: (x) => x.BilledInAdvance, + newSubscriptionThresholdTotalAmount: (x) => x.BilledInAdvance, + newSubscriptionTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionTieredWithMinimum: (x) => x.BilledInAdvance, + newSubscriptionGroupedTiered: (x) => x.BilledInAdvance, + newSubscriptionTieredPackageWithMinimum: (x) => x.BilledInAdvance, + newSubscriptionPackageWithAllocation: (x) => x.BilledInAdvance, + newSubscriptionUnitWithPercent: (x) => x.BilledInAdvance, + newSubscriptionMatrixWithAllocation: (x) => x.BilledInAdvance, + tieredWithProration: (x) => x.BilledInAdvance, + newSubscriptionUnitWithProration: (x) => x.BilledInAdvance, + newSubscriptionGroupedAllocation: (x) => x.BilledInAdvance, + newSubscriptionBulkWithProration: (x) => x.BilledInAdvance, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BilledInAdvance, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, + groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, + newSubscriptionMatrixWithDisplayName: (x) => x.BilledInAdvance, + newSubscriptionGroupedTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionMaxGroupTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, + newSubscriptionCumulativeGroupedBulk: (x) => x.BilledInAdvance, + cumulativeGroupedAllocation: (x) => x.BilledInAdvance, + newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance ); } } - public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) - { - 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) + 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(JsonElement element) + public double? ConversionRate { - 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.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.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + public string? Currency { - value = this.Value as NewUsageDiscount; - 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.TryPickNewAmountDiscount(out var value)) { - /// // `value` is of type `NewAmountDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - value = this.Value as NewAmountDiscount; - 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.TryPickNewMinimum(out var value)) { - /// // `value` is of type `NewMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) + public string? ExternalPriceID { - value = this.Value as NewMinimum; - 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.TryPickNewMaximum(out var value)) { - /// // `value` is of type `NewMaximum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) + public double? FixedPriceQuantity { - 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.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 + ); } } - /// - /// 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? InvoiceGroupingKey { - 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.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 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 NewBillingCycleConfiguration? InvoicingCycleConfiguration { - if (this.Value == null) + get { - 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 ); } - this.Switch( - (newPercentageDiscount) => newPercentageDiscount.Validate(), - (newUsageDiscount) => newUsageDiscount.Validate(), - (newAmountDiscount) => newAmountDiscount.Validate(), - (newMinimum) => newMinimum.Validate(), - (newMaximum) => newMaximum.Validate() - ); - } - - public virtual bool Equals(ReplaceAdjustmentAdjustment? 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 ReplaceAdjustmentAdjustmentConverter : JsonConverter -{ - public override ReplaceAdjustmentAdjustment? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + public string? LicenseTypeID { - var element = JsonSerializer.Deserialize(ref reader, options); - string? adjustmentType; - try - { - adjustmentType = element.GetProperty("adjustment_type").GetString(); - } - catch + get { - adjustmentType = null; + 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 + ); } + } - switch (adjustmentType) + public string? ReferenceID + { + get { - 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); - } + return Match( + newSubscriptionUnit: (x) => x.ReferenceID, + newSubscriptionTiered: (x) => x.ReferenceID, + newSubscriptionBulk: (x) => x.ReferenceID, + bulkWithFilters: (x) => x.ReferenceID, + newSubscriptionPackage: (x) => x.ReferenceID, + newSubscriptionMatrix: (x) => x.ReferenceID, + newSubscriptionThresholdTotalAmount: (x) => x.ReferenceID, + newSubscriptionTieredPackage: (x) => x.ReferenceID, + newSubscriptionTieredWithMinimum: (x) => x.ReferenceID, + newSubscriptionGroupedTiered: (x) => x.ReferenceID, + newSubscriptionTieredPackageWithMinimum: (x) => x.ReferenceID, + newSubscriptionPackageWithAllocation: (x) => x.ReferenceID, + newSubscriptionUnitWithPercent: (x) => x.ReferenceID, + newSubscriptionMatrixWithAllocation: (x) => x.ReferenceID, + tieredWithProration: (x) => x.ReferenceID, + newSubscriptionUnitWithProration: (x) => x.ReferenceID, + newSubscriptionGroupedAllocation: (x) => x.ReferenceID, + newSubscriptionBulkWithProration: (x) => x.ReferenceID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ReferenceID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ReferenceID, + groupedWithMinMaxThresholds: (x) => x.ReferenceID, + newSubscriptionMatrixWithDisplayName: (x) => x.ReferenceID, + newSubscriptionGroupedTieredPackage: (x) => x.ReferenceID, + newSubscriptionMaxGroupTieredPackage: (x) => x.ReferenceID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ReferenceID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, + newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, + cumulativeGroupedAllocation: (x) => x.ReferenceID, + newSubscriptionMinimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID + ); } } - public override void Write( - Utf8JsonWriter writer, - ReplaceAdjustmentAdjustment value, - JsonSerializerOptions options - ) + public ReplacePricePrice(NewSubscriptionUnitPrice 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(NewSubscriptionTieredPrice 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(NewSubscriptionBulkPrice 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(ReplacePricePriceBulkWithFilters 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(NewSubscriptionPackagePrice 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(NewSubscriptionMatrixPrice 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( + NewSubscriptionThresholdTotalAmountPrice 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(NewSubscriptionTieredPackagePrice 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( + NewSubscriptionTieredWithMinimumPrice 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(NewSubscriptionGroupedTieredPrice 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( + NewSubscriptionTieredPackageWithMinimumPrice 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( + NewSubscriptionPackageWithAllocationPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public ReplacePrice(ReplacePrice replacePrice) - : base(replacePrice) { } + public ReplacePricePrice(NewSubscriptionUnitWithPercentPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public ReplacePrice(IReadOnlyDictionary rawData) + public ReplacePricePrice( + NewSubscriptionMatrixWithAllocationPrice value, + JsonElement? element = null + ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePrice(FrozenDictionary rawData) + public ReplacePricePrice( + ReplacePricePriceTieredWithProration 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( + NewSubscriptionUnitWithProrationPrice value, + JsonElement? element = null + ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public ReplacePrice(string replacesPriceID) - : this() + public ReplacePricePrice( + NewSubscriptionGroupedAllocationPrice 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( + NewSubscriptionBulkWithProrationPrice 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( + NewSubscriptionGroupedWithProratedMinimumPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - JsonElement? _element = null; + public ReplacePricePrice( + NewSubscriptionGroupedWithMeteredMinimumPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public JsonElement Json + public ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds 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( + NewSubscriptionMatrixWithDisplayNamePrice 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( + NewSubscriptionGroupedTieredPackagePrice 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( + NewSubscriptionMaxGroupTieredPackagePrice 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( + NewSubscriptionScalableMatrixWithUnitPricingPrice 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( + NewSubscriptionScalableMatrixWithTieredPricingPrice 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 ReplacePricePrice( + NewSubscriptionCumulativeGroupedBulkPrice 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 ReplacePricePrice( + ReplacePricePriceCumulativeGroupedAllocation 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 ReplacePricePrice( + NewSubscriptionMinimumCompositePrice 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 - { - 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 - ); - } - } - - public double? FixedPriceQuantity - { - 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 - ); - } - } - - public string? InvoiceGroupingKey - { - 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 - ); - } - } - - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - return Match( - newSubscriptionUnit: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTiered: (x) => x.InvoicingCycleConfiguration, - newSubscriptionBulk: (x) => x.InvoicingCycleConfiguration, - bulkWithFilters: (x) => x.InvoicingCycleConfiguration, - newSubscriptionPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrix: (x) => x.InvoicingCycleConfiguration, - newSubscriptionThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedTiered: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, - newSubscriptionUnitWithPercent: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, - tieredWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionUnitWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - newSubscriptionBulkWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, - newSubscriptionScalableMatrixWithTieredPricing: (x) => - x.InvoicingCycleConfiguration, - newSubscriptionCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMinimumComposite: (x) => x.InvoicingCycleConfiguration, - percent: (x) => x.InvoicingCycleConfiguration, - eventOutput: (x) => x.InvoicingCycleConfiguration - ); - } - } - - public string? ReferenceID - { - get - { - return Match( - newSubscriptionUnit: (x) => x.ReferenceID, - newSubscriptionTiered: (x) => x.ReferenceID, - newSubscriptionBulk: (x) => x.ReferenceID, - bulkWithFilters: (x) => x.ReferenceID, - newSubscriptionPackage: (x) => x.ReferenceID, - newSubscriptionMatrix: (x) => x.ReferenceID, - newSubscriptionThresholdTotalAmount: (x) => x.ReferenceID, - newSubscriptionTieredPackage: (x) => x.ReferenceID, - newSubscriptionTieredWithMinimum: (x) => x.ReferenceID, - newSubscriptionGroupedTiered: (x) => x.ReferenceID, - newSubscriptionTieredPackageWithMinimum: (x) => x.ReferenceID, - newSubscriptionPackageWithAllocation: (x) => x.ReferenceID, - newSubscriptionUnitWithPercent: (x) => x.ReferenceID, - newSubscriptionMatrixWithAllocation: (x) => x.ReferenceID, - tieredWithProration: (x) => x.ReferenceID, - newSubscriptionUnitWithProration: (x) => x.ReferenceID, - newSubscriptionGroupedAllocation: (x) => x.ReferenceID, - newSubscriptionBulkWithProration: (x) => x.ReferenceID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ReferenceID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ReferenceID, - groupedWithMinMaxThresholds: (x) => x.ReferenceID, - newSubscriptionMatrixWithDisplayName: (x) => x.ReferenceID, - newSubscriptionGroupedTieredPackage: (x) => x.ReferenceID, - newSubscriptionMaxGroupTieredPackage: (x) => x.ReferenceID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ReferenceID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, - newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, - cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, - newSubscriptionMinimumComposite: (x) => x.ReferenceID, - percent: (x) => x.ReferenceID, - eventOutput: (x) => x.ReferenceID - ); - } - } - - public ReplacePricePrice(NewSubscriptionUnitPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewSubscriptionTieredPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewSubscriptionBulkPrice value, JsonElement? element = null) + public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public ReplacePricePrice(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) + public ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) { this.Value = value; this._element = element; } - public ReplacePricePrice(NewSubscriptionPackagePrice value, JsonElement? element = null) + public ReplacePricePrice(JsonElement element) { - this.Value = value; this._element = element; } - 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.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 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.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; - } - - public ReplacePricePrice(NewSubscriptionTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionTieredWithMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewSubscriptionGroupedTieredPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewSubscriptionUnitWithPercentPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionMatrixWithAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - ReplacePricePriceTieredWithProration value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionMaxGroupTieredPackagePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(ReplacePricePriceMinimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionMinimumCompositePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(JsonElement element) - { - this._element = element; - } - - /// - /// Returns true and sets the 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) - { - value = this.Value as NewSubscriptionUnitPrice; - return value != null; - } - - /// - /// Returns true and sets the 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 - ) - { - value = this.Value as NewSubscriptionTieredPrice; - return value != null; + value = this.Value as NewSubscriptionTieredPrice; + return value != null; } /// @@ -12611,35 +11899,14 @@ 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 `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.TryPickNewSubscriptionMinimumComposite(out var value)) { - /// // `value` is of type `NewSubscriptionMinimumCompositePrice` + /// if (instance.TryPickNewSubscriptionMinimumComposite(out var value)) { + /// // `value` is of type `NewSubscriptionMinimumCompositePrice` /// Console.WriteLine(value); /// } /// @@ -12737,7 +12004,6 @@ public bool TryPickEventOutput([NotNullWhen(true)] out ReplacePricePriceEventOut /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (ReplacePricePriceMinimum value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, /// (ReplacePricePricePercent value) => {...}, /// (ReplacePricePriceEventOutput value) => {...} @@ -12774,7 +12040,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 @@ -12866,9 +12131,6 @@ public void Switch( case ReplacePricePriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case ReplacePricePriceMinimum value: - minimum(value); - break; case NewSubscriptionMinimumCompositePrice value: newSubscriptionMinimumComposite(value); break; @@ -12928,7 +12190,6 @@ public void Switch( /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (ReplacePricePriceMinimum value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, /// (ReplacePricePricePercent value) => {...}, /// (ReplacePricePriceEventOutput value) => {...} @@ -13001,7 +12262,6 @@ public T Match( T > newSubscriptionCumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func minimum, System::Func newSubscriptionMinimumComposite, System::Func percent, System::Func eventOutput @@ -13060,7 +12320,6 @@ public T Match( ReplacePricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation( value ), - ReplacePricePriceMinimum value => minimum(value), NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), ReplacePricePricePercent value => percent(value), ReplacePricePriceEventOutput value => eventOutput(value), @@ -13170,8 +12429,6 @@ 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); @@ -13236,17 +12493,16 @@ public override void Validate() (newSubscriptionCumulativeGroupedBulk) => newSubscriptionCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() ); } - public virtual bool Equals(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() { @@ -13254,7 +12510,49 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 @@ -13916,28 +13214,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 @@ -13959,983 +13235,13 @@ JsonSerializerOptions options // 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 - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); - } - init { this._rawData.Set("tier_lower_bound", value); } - } - - /// - public override void Validate() - { - _ = this.UnitAmount; - _ = this.TierLowerBound; - } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - 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 - ); - } -} - -[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] -public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } - - public ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePriceBulkWithFiltersConversionRateConfig(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 ReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - } - - /// - /// 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" - ), - }; - } - - public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); - - public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( - 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 ReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); - } - - public virtual bool Equals(ReplacePricePriceBulkWithFiltersConversionRateConfig? 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 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; - } - - switch (conversionRateType) - { - case "unit": + return new(element); + } + case "percent": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -14953,11 +13259,11 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "event_output": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -14977,39 +13283,54 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); + return new ReplacePricePrice(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceBulkWithFiltersConversionRateConfig value, + ReplacePricePrice? value, JsonSerializerOptions options ) { - JsonSerializer.Serialize(writer, value.Json, options); + JsonSerializer.Serialize(writer, value?.Json, options); } } [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceTieredWithProration, - ReplacePricePriceTieredWithProrationFromRaw + ReplacePricePriceBulkWithFilters, + ReplacePricePriceBulkWithFiltersFromRaw >) )] -public sealed record class ReplacePricePriceTieredWithProration : JsonModel +public sealed record class ReplacePricePriceBulkWithFilters : JsonModel { + /// + /// Configuration for bulk_with_filters pricing + /// + public required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_filters_config" + ); + } + init { this._rawData.Set("bulk_with_filters_config", value); } + } + /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -15054,21 +13375,6 @@ public required string Name init { this._rawData.Set("name", value); } } - /// - /// Configuration for tiered_with_proration pricing - /// - public required ReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "tiered_with_proration_config" - ); - } - init { this._rawData.Set("tiered_with_proration_config", value); } - } - /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -15128,12 +13434,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" ); } @@ -15224,6 +13530,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 @@ -15262,19 +13581,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(); @@ -15286,37 +13605,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceTieredWithProration() + public ReplacePricePriceBulkWithFilters() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public ReplacePricePriceTieredWithProration( - ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFilters( + ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters ) - : base(replacePricePriceTieredWithProration) { } + : base(replacePricePriceBulkWithFilters) { } +#pragma warning restore CS8618 - public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) + public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProration(FrozenDictionary rawData) + ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceTieredWithProration FromRawUnchecked( + /// + public static ReplacePricePriceBulkWithFilters FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15324,124 +13647,178 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceTieredWithProrationFromRaw - : IFromRawJson +class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson { /// - public ReplacePricePriceTieredWithProration FromRawUnchecked( + public ReplacePricePriceBulkWithFilters FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceTieredWithProration.FromRawUnchecked(rawData); + ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); } /// -/// The cadence to bill for this price on. +/// Configuration for bulk_with_filters pricing /// -[JsonConverter(typeof(ReplacePricePriceTieredWithProrationCadenceConverter))] -public enum ReplacePricePriceTieredWithProrationCadence +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : 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 ReplacePricePriceTieredWithProrationCadenceConverter - : JsonConverter -{ - public override ReplacePricePriceTieredWithProrationCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + /// Bulk tiers for rating based on total usage volume + /// + public required IReadOnlyList Tiers { - return JsonSerializer.Deserialize(ref reader, options) switch + get { - "annual" => ReplacePricePriceTieredWithProrationCadence.Annual, - "semi_annual" => ReplacePricePriceTieredWithProrationCadence.SemiAnnual, - "monthly" => ReplacePricePriceTieredWithProrationCadence.Monthly, - "quarterly" => ReplacePricePriceTieredWithProrationCadence.Quarterly, - "one_time" => ReplacePricePriceTieredWithProrationCadence.OneTime, - "custom" => ReplacePricePriceTieredWithProrationCadence.Custom, - _ => (ReplacePricePriceTieredWithProrationCadence)(-1), - }; + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); + } } - public override void Write( - Utf8JsonWriter writer, - ReplacePricePriceTieredWithProrationCadence value, - JsonSerializerOptions options + /// + public override void Validate() + { + foreach (var item in this.Filters) + { + item.Validate(); + } + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig + ) + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + IReadOnlyDictionary rawData ) { - 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 - ); + 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 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 - public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( IReadOnlyDictionary rawData ) { @@ -15450,7 +13827,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( FrozenDictionary rawData ) { @@ -15458,86 +13835,79 @@ 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier ) - : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( IReadOnlyDictionary rawData ) { @@ -15546,7 +13916,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( FrozenDictionary rawData ) { @@ -15554,27 +13924,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 ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw - : IFromRawJson +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson { /// - public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); } -[JsonConverter(typeof(ReplacePricePriceTieredWithProrationConversionRateConfigConverter))] -public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase +/// +/// 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 + ); + } +} + +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] +public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -15591,7 +14027,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15600,7 +14036,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15609,7 +14045,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -15691,7 +14127,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" ); } } @@ -15727,16 +14163,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -15755,16 +14191,16 @@ 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) - { - 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() { @@ -15772,13 +14208,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceTieredWithProrationConversionRateConfig? Read( + public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -15843,14 +14292,14 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); + return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceTieredWithProrationConversionRateConfig value, + ReplacePricePriceBulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -15860,40 +14309,25 @@ 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 - { - 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 ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required ApiEnum Cadence { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "grouped_with_min_max_thresholds_config" - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); } - init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + init { this._rawData.Set("cadence", value); } } /// @@ -15935,6 +14369,21 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for tiered_with_proration pricing + /// + public required ReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_proration_config" + ); + } + init { this._rawData.Set("tiered_with_proration_config", value); } + } + /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -15994,12 +14443,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" ); } @@ -16090,6 +14539,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 @@ -16129,18 +14591,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(); @@ -16152,39 +14614,41 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProration( + ReplacePricePriceTieredWithProration replacePricePriceTieredWithProration ) - : base(replacePricePriceGroupedWithMinMaxThresholds) { } + : base(replacePricePriceTieredWithProration) { } +#pragma warning restore CS8618 - public ReplacePricePriceGroupedWithMinMaxThresholds( - IReadOnlyDictionary rawData - ) + public ReplacePricePriceTieredWithProration(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) + ReplacePricePriceTieredWithProration(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16192,20 +14656,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationFromRaw + : IFromRawJson { /// - public ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public ReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => ReplacePricePriceTieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter))] -public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationCadenceConverter))] +public enum ReplacePricePriceTieredWithProrationCadence { Annual, SemiAnnual, @@ -16215,10 +14679,10 @@ public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence Custom, } -sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class ReplacePricePriceTieredWithProrationCadenceConverter + : JsonConverter { - public override ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( + public override ReplacePricePriceTieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16226,19 +14690,19 @@ 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, + ReplacePricePriceTieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -16246,12 +14710,12 @@ JsonSerializerOptions options writer, value switch { - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", + ReplacePricePriceTieredWithProrationCadence.Annual => "annual", + ReplacePricePriceTieredWithProrationCadence.SemiAnnual => "semi_annual", + ReplacePricePriceTieredWithProrationCadence.Monthly => "monthly", + ReplacePricePriceTieredWithProrationCadence.Quarterly => "quarterly", + ReplacePricePriceTieredWithProrationCadence.OneTime => "one_time", + ReplacePricePriceTieredWithProrationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -16262,86 +14726,156 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for tiered_with_proration pricing /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + ReplacePricePriceTieredWithProrationTieredWithProrationConfig, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw >) )] -public sealed record class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig - : JsonModel +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration /// - public required string GroupingKey + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); } - init { this._rawData.Set("grouping_key", value); } } - /// - /// The maximum amount to charge each group - /// - public required string MaximumCharge + /// + public override void Validate() { - get + foreach (var item in this.Tiers) { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + item.Validate(); } - init { this._rawData.Set("maximum_charge", value); } } + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfig replacePricePriceTieredWithProrationTieredWithProrationConfig + ) + : base(replacePricePriceTieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 + + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + IReadOnlyList tiers + ) + : this() + { + this.Tiers = tiers; + } +} + +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tiered with proration tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + >) +)] +public sealed record class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + : JsonModel +{ /// - /// The minimum amount to charge each group, regardless of usage + /// Inclusive tier starting value /// - public required string MinimumCharge + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// - /// The base price charged per group + /// Amount per unit /// - public required string PerUnitRate + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("per_unit_rate", value); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.TierLowerBound; + _ = this.UnitAmount; } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier replacePricePriceTieredWithProrationTieredWithProrationConfigTier ) - : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } + : base(replacePricePriceTieredWithProrationTieredWithProrationConfigTier) { } +#pragma warning restore CS8618 - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData ) { @@ -16350,7 +14884,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -16358,8 +14892,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16367,20 +14901,18 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class ReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson { /// - public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) => - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( - rawData - ); + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] -public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceTieredWithProrationConversionRateConfigConverter))] +public record class ReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -16397,7 +14929,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16406,7 +14938,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16415,7 +14947,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -16497,7 +15029,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ); } } @@ -16533,16 +15065,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of ReplacePricePriceTieredWithProrationConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16561,18 +15093,16 @@ 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 - ) - { - 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() { @@ -16580,13 +15110,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceTieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override ReplacePricePriceTieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16651,16 +15194,14 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new ReplacePricePriceTieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + ReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -16670,40 +15211,40 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceCumulativeGroupedAllocation, - ReplacePricePriceCumulativeGroupedAllocationFromRaw + ReplacePricePriceGroupedWithMinMaxThresholds, + ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonModel +public sealed record class ReplacePricePriceGroupedWithMinMaxThresholds : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// Configuration for cumulative_grouped_allocation pricing + /// Configuration for grouped_with_min_max_thresholds pricing /// - public required ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" + return this._rawData.GetNotNullClass( + "grouped_with_min_max_thresholds_config" ); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } } /// @@ -16804,12 +15345,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" ); } @@ -16900,6 +15441,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 @@ -16939,12 +15493,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") ) ) { @@ -16962,39 +15516,43 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceGroupedWithMinMaxThresholds( + ReplacePricePriceGroupedWithMinMaxThresholds replacePricePriceGroupedWithMinMaxThresholds ) - : base(replacePricePriceCumulativeGroupedAllocation) { } + : base(replacePricePriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 - public ReplacePricePriceCumulativeGroupedAllocation( + public ReplacePricePriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) + ReplacePricePriceGroupedWithMinMaxThresholds(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17002,20 +15560,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => ReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationCadenceConverter))] -public enum ReplacePricePriceCumulativeGroupedAllocationCadence +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter))] +public enum ReplacePricePriceGroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -17025,10 +15583,10 @@ public enum ReplacePricePriceCumulativeGroupedAllocationCadence Custom, } -sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class ReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override ReplacePricePriceCumulativeGroupedAllocationCadence Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17036,19 +15594,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - "semi_annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual, - "monthly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly, - "quarterly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly, - "one_time" => ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime, - "custom" => ReplacePricePriceCumulativeGroupedAllocationCadence.Custom, - _ => (ReplacePricePriceCumulativeGroupedAllocationCadence)(-1), + "annual" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom, + _ => (ReplacePricePriceGroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationCadence value, + ReplacePricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -17056,12 +15614,12 @@ JsonSerializerOptions options writer, value switch { - ReplacePricePriceCumulativeGroupedAllocationCadence.Annual => "annual", - ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", - ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly => "monthly", - ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", - ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime => "one_time", - ReplacePricePriceCumulativeGroupedAllocationCadence.Custom => "custom", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -17072,86 +15630,89 @@ 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) - : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } + : base(replacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData ) { @@ -17160,7 +15721,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -17168,8 +15729,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17177,20 +15738,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( rawData ); } -[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] -public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -17207,7 +15768,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17216,7 +15777,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17225,7 +15786,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -17307,7 +15868,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -17343,16 +15904,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -17371,18 +15932,18 @@ 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 - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -17390,13 +15951,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( + public override ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17461,7 +16035,7 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -17470,7 +16044,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -17479,51 +16053,54 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter) + typeof(JsonModelConverter< + ReplacePricePriceCumulativeGroupedAllocation, + ReplacePricePriceCumulativeGroupedAllocationFromRaw + >) )] -public sealed record class ReplacePricePriceMinimum : JsonModel +public sealed record class ReplacePricePriceCumulativeGroupedAllocation : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "cadence" - ); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// The id of the item the price will be associated with. + /// Configuration for cumulative_grouped_allocation pricing /// - public required string ItemID + public required ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } } /// - /// Configuration for minimum pricing + /// The id of the item the price will be associated with. /// - public required ReplacePricePriceMinimumMinimumConfig MinimumConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("item_id", value); } } /// @@ -17611,12 +16188,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" ); } @@ -17707,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 @@ -17746,9 +16336,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"); } @@ -17764,35 +16359,43 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public ReplacePricePriceMinimum() + public ReplacePricePriceCumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public ReplacePricePriceMinimum(ReplacePricePriceMinimum replacePricePriceMinimum) - : base(replacePricePriceMinimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceCumulativeGroupedAllocation( + ReplacePricePriceCumulativeGroupedAllocation replacePricePriceCumulativeGroupedAllocation + ) + : base(replacePricePriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public ReplacePricePriceMinimum(IReadOnlyDictionary rawData) + public ReplacePricePriceCumulativeGroupedAllocation( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimum(FrozenDictionary rawData) + ReplacePricePriceCumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceMinimum FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17800,19 +16403,20 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceMinimumFromRaw : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public ReplacePricePriceMinimum FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceMinimum.FromRawUnchecked(rawData); + ) => ReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(ReplacePricePriceMinimumCadenceConverter))] -public enum ReplacePricePriceMinimumCadence +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationCadenceConverter))] +public enum ReplacePricePriceCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -17822,10 +16426,10 @@ public enum ReplacePricePriceMinimumCadence Custom, } -sealed class ReplacePricePriceMinimumCadenceConverter - : JsonConverter +sealed class ReplacePricePriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override ReplacePricePriceMinimumCadence Read( + public override ReplacePricePriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17833,19 +16437,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => ReplacePricePriceMinimumCadence.Annual, - "semi_annual" => ReplacePricePriceMinimumCadence.SemiAnnual, - "monthly" => ReplacePricePriceMinimumCadence.Monthly, - "quarterly" => ReplacePricePriceMinimumCadence.Quarterly, - "one_time" => ReplacePricePriceMinimumCadence.OneTime, - "custom" => ReplacePricePriceMinimumCadence.Custom, - _ => (ReplacePricePriceMinimumCadence)(-1), + "annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + "semi_annual" => ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly, + "quarterly" => ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly, + "one_time" => ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime, + "custom" => ReplacePricePriceCumulativeGroupedAllocationCadence.Custom, + _ => (ReplacePricePriceCumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceMinimumCadence value, + ReplacePricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -17853,12 +16457,12 @@ JsonSerializerOptions options writer, value switch { - ReplacePricePriceMinimumCadence.Annual => "annual", - ReplacePricePriceMinimumCadence.SemiAnnual => "semi_annual", - ReplacePricePriceMinimumCadence.Monthly => "monthly", - ReplacePricePriceMinimumCadence.Quarterly => "quarterly", - ReplacePricePriceMinimumCadence.OneTime => "one_time", - ReplacePricePriceMinimumCadence.Custom => "custom", + ReplacePricePriceCumulativeGroupedAllocationCadence.Annual => "annual", + ReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + ReplacePricePriceCumulativeGroupedAllocationCadence.Monthly => "monthly", + ReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", + ReplacePricePriceCumulativeGroupedAllocationCadence.OneTime => "one_time", + ReplacePricePriceCumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -17869,104 +16473,128 @@ 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) - : base(replacePricePriceMinimumMinimumConfig) { } + : base(replacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 - public ReplacePricePriceMinimumMinimumConfig(IReadOnlyDictionary rawData) + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceMinimumMinimumConfig(FrozenDictionary rawData) + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public ReplacePricePriceMinimumMinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class ReplacePricePriceMinimumMinimumConfigFromRaw - : IFromRawJson +class ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public ReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + public ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceMinimumMinimumConfig.FromRawUnchecked(rawData); + ) => + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + rawData + ); } -[JsonConverter(typeof(ReplacePricePriceMinimumConversionRateConfigConverter))] -public record class ReplacePricePriceMinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter))] +public record class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -17983,7 +16611,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17992,7 +16620,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -18001,7 +16629,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -18083,7 +16711,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -18119,16 +16747,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator ReplacePricePriceMinimumConversionRateConfig( + public static implicit operator ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -18147,16 +16775,18 @@ 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) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals( + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -18164,13 +16794,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class ReplacePricePriceMinimumConversionRateConfigConverter - : JsonConverter +sealed class ReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceMinimumConversionRateConfig? Read( + public override ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -18235,14 +16878,16 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceMinimumConversionRateConfig(element); + return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + element + ); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceMinimumConversionRateConfig value, + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -18479,6 +17124,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 @@ -18536,6 +17194,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -18545,8 +17204,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) { @@ -18672,10 +17334,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) { @@ -18903,10 +17568,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() { @@ -18914,7 +17579,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePricePercentConversionRateConfigConverter @@ -19229,6 +17907,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 @@ -19291,6 +17982,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -19300,8 +17992,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) { @@ -19458,10 +18153,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 @@ -19691,10 +18389,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() { @@ -19702,7 +18400,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ReplacePricePriceEventOutputConversionRateConfigConverter diff --git a/src/Orb/Models/Subscriptions/SubscriptionFetchCostsParams.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchCostsParams.cs index 5dfc70260..a9d1a9213 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +174,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/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/SubscriptionFetchParams.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchParams.cs index 3a5ac6bd6..6033b3c64 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Subscriptions/SubscriptionFetchSchedulePage.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchSchedulePage.cs index 7c1830f3a..c2cba5668 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; @@ -66,5 +67,20 @@ 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) + { + 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/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/SubscriptionFetchScheduleParams.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchScheduleParams.cs index c273879a6..a85dd81bc 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +189,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/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/SubscriptionFetchUsageParams.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchUsageParams.cs index 43e4d51f2..8eb20b1f2 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +361,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/SubscriptionListPage.cs b/src/Orb/Models/Subscriptions/SubscriptionListPage.cs index d905b0f4f..7ccdab2f4 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; @@ -62,5 +63,20 @@ 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) + { + 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/Subscriptions/SubscriptionListParams.cs b/src/Orb/Models/Subscriptions/SubscriptionListParams.cs index e2d4fbec0..30ce4170b 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionListParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionListParams.cs @@ -19,8 +19,12 @@ namespace Orb.Models.Subscriptions; /// Subscriptions can be filtered for a specific customer by using either the /// customer_id or external_customer_id query parameters. To filter subscriptions /// for multiple customers, use the customer_id[] or external_customer_id[] query parameters. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionListParams : ParamsBase +public record class SubscriptionListParams : ParamsBase { public System::DateTimeOffset? CreatedAtGt { @@ -151,22 +155,23 @@ public string? PlanID init { this._rawQueryData.Set("plan_id", value); } } - public ApiEnum? Status + public ApiEnum? Status { get { this._rawQueryData.Freeze(); - return this._rawQueryData.GetNullableClass< - ApiEnum - >("status"); + return this._rawQueryData.GetNullableClass>("status"); } init { this._rawQueryData.Set("status", value); } } public SubscriptionListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionListParams(SubscriptionListParams subscriptionListParams) : base(subscriptionListParams) { } +#pragma warning restore CS8618 public SubscriptionListParams( IReadOnlyDictionary rawHeaderData, @@ -201,6 +206,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/subscriptions") @@ -217,9 +248,14 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter(typeof(global::Orb.Models.Subscriptions.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { Active, @@ -227,9 +263,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 +273,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..57830167f 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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))] @@ -349,18 +391,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 +452,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) ); @@ -444,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. @@ -526,6 +588,7 @@ public override void Validate() item.Validate(); } _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; _ = this.MinimumAmount; this.Price?.Validate(); _ = this.PriceID; @@ -534,8 +597,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) { @@ -752,10 +818,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() { @@ -763,7 +829,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class StartDateConverter : JsonConverter @@ -793,7 +872,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) { @@ -1009,14 +1091,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,10 +1120,10 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Subscriptions.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() { @@ -1052,12 +1131,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + Amount _ => 0, + Percentage _ => 1, + Usage _ => 2, + _ => -1, + }; + } } -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 +1228,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); } @@ -1191,8 +1280,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) { @@ -1277,8 +1369,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) { @@ -1358,8 +1453,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) { @@ -1578,10 +1676,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() { @@ -1589,7 +1687,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class EndDateConverter : JsonConverter @@ -1619,7 +1730,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) { @@ -1636,10 +1750,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,10 +1789,11 @@ public override void Validate() public FixedFeeQuantityTransition() { } - public FixedFeeQuantityTransition( - global::Orb.Models.Subscriptions.FixedFeeQuantityTransition fixedFeeQuantityTransition - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FixedFeeQuantityTransition(FixedFeeQuantityTransition fixedFeeQuantityTransition) : base(fixedFeeQuantityTransition) { } +#pragma warning restore CS8618 public FixedFeeQuantityTransition(IReadOnlyDictionary rawData) { @@ -1696,8 +1808,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 +1817,12 @@ IReadOnlyDictionary rawData } } -class FixedFeeQuantityTransitionFromRaw - : IFromRawJson +class FixedFeeQuantityTransitionFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.FixedFeeQuantityTransition FromRawUnchecked( + public FixedFeeQuantityTransition FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.FixedFeeQuantityTransition.FromRawUnchecked(rawData); + ) => FixedFeeQuantityTransition.FromRawUnchecked(rawData); } /// @@ -1768,7 +1879,6 @@ public string Currency newFloatingScalableMatrixWithTieredPricing: (x) => x.Currency, newFloatingCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, newFloatingMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -1809,7 +1919,6 @@ public string ItemID newFloatingScalableMatrixWithTieredPricing: (x) => x.ItemID, newFloatingCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, newFloatingMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -1850,7 +1959,6 @@ public string Name newFloatingScalableMatrixWithTieredPricing: (x) => x.Name, newFloatingCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, newFloatingMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -1891,7 +1999,6 @@ public string? BillableMetricID newFloatingScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newFloatingCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, newFloatingMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -1932,7 +2039,6 @@ public bool? BilledInAdvance newFloatingScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newFloatingCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, newFloatingMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -1973,7 +2079,6 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, newFloatingMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -2014,7 +2119,6 @@ public double? ConversionRate newFloatingScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newFloatingCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, newFloatingMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -2055,7 +2159,6 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration newFloatingScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, newFloatingCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, newFloatingMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -2096,7 +2199,6 @@ public string? ExternalPriceID newFloatingScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newFloatingCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, newFloatingMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -2137,7 +2239,6 @@ public double? FixedPriceQuantity newFloatingScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newFloatingCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, newFloatingMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -2178,7 +2279,6 @@ public string? InvoiceGroupingKey newFloatingScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newFloatingCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, newFloatingMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -2219,7 +2319,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 @@ -2227,6 +2326,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; @@ -2401,12 +2540,6 @@ public PriceModel(PriceModelCumulativeGroupedAllocation value, JsonElement? elem this._element = element; } - public PriceModel(PriceModelMinimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - public PriceModel(NewFloatingMinimumCompositePrice value, JsonElement? element = null) { this.Value = value; @@ -3062,27 +3195,6 @@ public bool TryPickCumulativeGroupedAllocation( return value != null; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `PriceModelMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out PriceModelMinimum? value) - { - value = this.Value as PriceModelMinimum; - return value != null; - } - /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . @@ -3190,7 +3302,6 @@ public bool TryPickEventOutput([NotNullWhen(true)] out PriceModelEventOutput? va /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceModelCumulativeGroupedAllocation value) => {...}, - /// (PriceModelMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PriceModelPercent value) => {...}, /// (PriceModelEventOutput value) => {...} @@ -3227,7 +3338,6 @@ public void Switch( System::Action newFloatingScalableMatrixWithTieredPricing, System::Action newFloatingCumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, System::Action newFloatingMinimumComposite, System::Action percent, System::Action eventOutput @@ -3319,9 +3429,6 @@ public void Switch( case PriceModelCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case PriceModelMinimum value: - minimum(value); - break; case NewFloatingMinimumCompositePrice value: newFloatingMinimumComposite(value); break; @@ -3379,7 +3486,6 @@ public void Switch( /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, /// (PriceModelCumulativeGroupedAllocation value) => {...}, - /// (PriceModelMinimum value) => {...}, /// (NewFloatingMinimumCompositePrice value) => {...}, /// (PriceModelPercent value) => {...}, /// (PriceModelEventOutput value) => {...} @@ -3431,7 +3537,6 @@ public T Match( > newFloatingScalableMatrixWithTieredPricing, System::Func newFloatingCumulativeGroupedBulk, System::Func cumulativeGroupedAllocation, - System::Func minimum, System::Func newFloatingMinimumComposite, System::Func percent, System::Func eventOutput @@ -3474,7 +3579,6 @@ public T Match( newFloatingScalableMatrixWithTieredPricing(value), NewFloatingCumulativeGroupedBulkPrice value => newFloatingCumulativeGroupedBulk(value), PriceModelCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - PriceModelMinimum value => minimum(value), NewFloatingMinimumCompositePrice value => newFloatingMinimumComposite(value), PriceModelPercent value => percent(value), PriceModelEventOutput value => eventOutput(value), @@ -3559,8 +3663,6 @@ public static implicit operator PriceModel(NewFloatingCumulativeGroupedBulkPrice public static implicit operator PriceModel(PriceModelCumulativeGroupedAllocation value) => new(value); - public static implicit operator PriceModel(PriceModelMinimum value) => new(value); - public static implicit operator PriceModel(NewFloatingMinimumCompositePrice value) => new(value); @@ -3617,17 +3719,16 @@ public override void Validate() newFloatingScalableMatrixWithTieredPricing.Validate(), (newFloatingCumulativeGroupedBulk) => newFloatingCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newFloatingMinimumComposite) => newFloatingMinimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() ); } - public virtual bool Equals(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() { @@ -3635,7 +3736,49 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 @@ -4294,28 +4437,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 @@ -4627,6 +4748,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 @@ -4675,6 +4809,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4683,8 +4818,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) { @@ -4786,10 +4924,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 @@ -4870,10 +5011,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 @@ -4956,10 +5100,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 @@ -5251,10 +5398,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() { @@ -5262,7 +5409,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceModelBulkWithFiltersConversionRateConfigConverter @@ -5579,6 +5739,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 @@ -5627,6 +5800,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -5635,10 +5809,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) { @@ -5808,10 +5985,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 @@ -6039,10 +6219,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() { @@ -6050,7 +6230,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceModelGroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -6367,6 +6560,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 @@ -6415,6 +6621,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -6423,10 +6630,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) { @@ -6596,10 +6806,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 @@ -6827,10 +7040,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() { @@ -6838,7 +7051,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceModelCumulativeGroupedAllocationConversionRateConfigConverter @@ -6924,18 +7150,18 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class PriceModelMinimum : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PriceModelPercent : 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>( + return this._rawData.GetNotNullClass>( "cadence" ); } @@ -6968,19 +7194,6 @@ public required string ItemID 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 /// @@ -7008,745 +7221,9 @@ public required string Name } /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// Configuration for percent pricing /// - 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 -{ - /// - /// 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); } - } - - /// - /// 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 PriceModelPercentPercentConfig PercentConfig + public required PriceModelPercentPercentConfig PercentConfig { get { @@ -7897,6 +7374,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 @@ -7940,6 +7430,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7948,8 +7439,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) { @@ -8073,10 +7567,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) { @@ -8303,10 +7800,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() { @@ -8314,7 +7811,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceModelPercentConversionRateConfigConverter @@ -8626,6 +8136,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 @@ -8674,6 +8197,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -8682,8 +8206,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) { @@ -8839,10 +8366,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) { @@ -9070,10 +8600,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() { @@ -9081,7 +8611,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceModelEventOutputConversionRateConfigConverter @@ -9252,10 +8795,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 @@ -9499,10 +9045,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() { @@ -9510,7 +9056,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class SubscriptionPriceIntervalsParamsAddAdjustmentStartDateConverter @@ -9541,7 +9100,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) { @@ -9912,10 +9474,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() { @@ -9923,7 +9485,23 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + 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 SubscriptionPriceIntervalsParamsAddAdjustmentAdjustmentConverter @@ -10269,10 +9847,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() { @@ -10280,7 +9858,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class SubscriptionPriceIntervalsParamsAddAdjustmentEndDateConverter @@ -10311,7 +9902,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) { @@ -10429,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. @@ -10487,14 +10103,18 @@ public override void Validate() { item.Validate(); } + _ = this.MetricParameterOverrides; this.StartDate?.Validate(); _ = this.UsageCustomerIds; } public Edit() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Edit(Edit edit) : base(edit) { } +#pragma warning restore CS8618 public Edit(IReadOnlyDictionary rawData) { @@ -10711,10 +10331,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() { @@ -10722,7 +10342,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class EditEndDateConverter : JsonConverter @@ -10752,7 +10385,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) { @@ -10815,10 +10451,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) { @@ -11039,10 +10678,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() { @@ -11050,7 +10689,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class EditStartDateConverter : JsonConverter @@ -11080,7 +10732,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) { @@ -11162,8 +10817,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) { @@ -11392,10 +11050,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() { @@ -11403,7 +11061,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class EditAdjustmentEndDateConverter : JsonConverter @@ -11433,7 +11104,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) { @@ -11646,10 +11320,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() { @@ -11657,7 +11331,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class EditAdjustmentStartDateConverter : JsonConverter @@ -11687,7 +11374,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/SubscriptionRedeemCouponParams.cs b/src/Orb/Models/Subscriptions/SubscriptionRedeemCouponParams.cs index 392cb3fd7..a49285027 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +207,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..598917d88 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +727,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsChangeOptionConverter))] @@ -818,10 +860,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 @@ -1216,10 +1261,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() { @@ -1227,7 +1274,23 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + 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 SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustmentConverter @@ -1457,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. @@ -1539,6 +1624,7 @@ public override void Validate() _ = this.EndDate; _ = this.ExternalPriceID; _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; _ = this.MinimumAmount; _ = this.PlanPhaseOrder; this.Price?.Validate(); @@ -1548,10 +1634,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 @@ -1640,7 +1729,6 @@ public string ItemID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ItemID, newSubscriptionCumulativeGroupedBulk: (x) => x.ItemID, cumulativeGroupedAllocation: (x) => x.ItemID, - minimum: (x) => x.ItemID, newSubscriptionMinimumComposite: (x) => x.ItemID, percent: (x) => x.ItemID, eventOutput: (x) => x.ItemID @@ -1681,7 +1769,6 @@ public string Name newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Name, newSubscriptionCumulativeGroupedBulk: (x) => x.Name, cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, newSubscriptionMinimumComposite: (x) => x.Name, percent: (x) => x.Name, eventOutput: (x) => x.Name @@ -1722,7 +1809,6 @@ public string? BillableMetricID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, newSubscriptionCumulativeGroupedBulk: (x) => x.BillableMetricID, cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, newSubscriptionMinimumComposite: (x) => x.BillableMetricID, percent: (x) => x.BillableMetricID, eventOutput: (x) => x.BillableMetricID @@ -1763,7 +1849,6 @@ public bool? BilledInAdvance newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, newSubscriptionCumulativeGroupedBulk: (x) => x.BilledInAdvance, cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, percent: (x) => x.BilledInAdvance, eventOutput: (x) => x.BilledInAdvance @@ -1804,7 +1889,6 @@ public NewBillingCycleConfiguration? BillingCycleConfiguration newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, percent: (x) => x.BillingCycleConfiguration, eventOutput: (x) => x.BillingCycleConfiguration @@ -1845,7 +1929,6 @@ public double? ConversionRate newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ConversionRate, newSubscriptionCumulativeGroupedBulk: (x) => x.ConversionRate, cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, newSubscriptionMinimumComposite: (x) => x.ConversionRate, percent: (x) => x.ConversionRate, eventOutput: (x) => x.ConversionRate @@ -1886,7 +1969,6 @@ public string? Currency newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Currency, newSubscriptionCumulativeGroupedBulk: (x) => x.Currency, cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, newSubscriptionMinimumComposite: (x) => x.Currency, percent: (x) => x.Currency, eventOutput: (x) => x.Currency @@ -1929,7 +2011,6 @@ public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration x.DimensionalPriceConfiguration, newSubscriptionCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, percent: (x) => x.DimensionalPriceConfiguration, eventOutput: (x) => x.DimensionalPriceConfiguration @@ -1970,7 +2051,6 @@ public string? ExternalPriceID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, newSubscriptionCumulativeGroupedBulk: (x) => x.ExternalPriceID, cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, percent: (x) => x.ExternalPriceID, eventOutput: (x) => x.ExternalPriceID @@ -2011,7 +2091,6 @@ public double? FixedPriceQuantity newSubscriptionScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, newSubscriptionCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, percent: (x) => x.FixedPriceQuantity, eventOutput: (x) => x.FixedPriceQuantity @@ -2052,7 +2131,6 @@ public string? InvoiceGroupingKey newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, percent: (x) => x.InvoiceGroupingKey, eventOutput: (x) => x.InvoiceGroupingKey @@ -2094,7 +2172,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 @@ -2102,6 +2179,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 @@ -2135,7 +2252,6 @@ public string? ReferenceID newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, newSubscriptionMinimumComposite: (x) => x.ReferenceID, percent: (x) => x.ReferenceID, eventOutput: (x) => x.ReferenceID @@ -2395,15 +2511,6 @@ public SubscriptionSchedulePlanChangeParamsAddPricePrice( this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePrice( - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - public SubscriptionSchedulePlanChangeParamsAddPricePrice( NewSubscriptionMinimumCompositePrice value, JsonElement? element = null @@ -3084,29 +3191,6 @@ out SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation return value != null; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] out SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum? value - ) - { - value = this.Value as SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum; - return value != null; - } - /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . @@ -3218,7 +3302,6 @@ public bool TryPickEventOutput( /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePricePercent value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value) => {...} @@ -3255,7 +3338,6 @@ public void Switch( System::Action newSubscriptionScalableMatrixWithTieredPricing, System::Action newSubscriptionCumulativeGroupedBulk, System::Action cumulativeGroupedAllocation, - System::Action minimum, System::Action newSubscriptionMinimumComposite, System::Action percent, System::Action eventOutput @@ -3347,9 +3429,6 @@ public void Switch( case SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value: - minimum(value); - break; case NewSubscriptionMinimumCompositePrice value: newSubscriptionMinimumComposite(value); break; @@ -3409,7 +3488,6 @@ public void Switch( /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value) => {...}, /// (NewSubscriptionMinimumCompositePrice value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePricePercent value) => {...}, /// (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value) => {...} @@ -3494,7 +3572,6 @@ public T Match( SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation, T > cumulativeGroupedAllocation, - System::Func minimum, System::Func newSubscriptionMinimumComposite, System::Func percent, System::Func eventOutput @@ -3553,7 +3630,6 @@ public T Match( ), SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value => minimum(value), NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), SubscriptionSchedulePlanChangeParamsAddPricePricePercent value => percent(value), SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value => eventOutput( @@ -3677,10 +3753,6 @@ public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePric SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePrice( - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value - ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePrice( NewSubscriptionMinimumCompositePrice value ) => new(value); @@ -3749,17 +3821,16 @@ public override void Validate() (newSubscriptionCumulativeGroupedBulk) => newSubscriptionCumulativeGroupedBulk.Validate(), (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), (percent) => percent.Validate(), (eventOutput) => eventOutput.Validate() ); } - public virtual bool Equals(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() { @@ -3767,7 +3838,49 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + 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 @@ -4431,29 +4544,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 @@ -4779,6 +4869,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 @@ -4841,6 +4944,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -4850,10 +4954,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 @@ -4960,12 +5067,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 @@ -5053,12 +5163,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 @@ -5146,12 +5259,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 @@ -5469,10 +5585,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() { @@ -5480,7 +5596,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfigConverter @@ -5807,6 +5936,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 @@ -5869,6 +6011,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -5878,10 +6021,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 @@ -6042,12 +6188,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 @@ -6144,12 +6293,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 @@ -6384,10 +6536,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() { @@ -6395,7 +6547,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfigConverter @@ -6722,6 +6887,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 @@ -6784,6 +6962,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -6793,10 +6972,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 @@ -6991,12 +7173,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 @@ -7231,10 +7416,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() { @@ -7242,7 +7427,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -7569,6 +7767,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 @@ -7631,6 +7842,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -7640,10 +7852,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 @@ -7838,12 +8053,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 @@ -8078,10 +8296,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() { @@ -8089,7 +8307,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfigConverter @@ -8179,25 +8410,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); } @@ -8216,21 +8447,6 @@ public required string ItemID init { this._rawData.Set("item_id", value); } } - /// - /// Configuration for minimum pricing - /// - public required SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig MinimumConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); - } - init { this._rawData.Set("minimum_config", value); } - } - /// /// The pricing model type /// @@ -8258,7 +8474,22 @@ public required string Name } /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// 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. /// public string? BillableMetricID { @@ -8316,12 +8547,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" ); } @@ -8412,6 +8643,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 @@ -8452,12 +8696,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(); @@ -8469,32 +8713,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum() + public SubscriptionSchedulePlanChangeParamsAddPricePricePercent() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum( - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum subscriptionSchedulePlanChangeParamsAddPricePriceMinimum +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( + SubscriptionSchedulePlanChangeParamsAddPricePricePercent subscriptionSchedulePlanChangeParamsAddPricePricePercent ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceMinimum) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePricePercent) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum( + SubscriptionSchedulePlanChangeParamsAddPricePricePercent( FrozenDictionary rawData ) { @@ -8502,8 +8750,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8511,20 +8759,20 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePricePercentFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum.FromRawUnchecked(rawData); + ) => SubscriptionSchedulePlanChangeParamsAddPricePricePercent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadenceConverter))] -public enum SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence +[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceConverter))] +public enum SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence { Annual, SemiAnnual, @@ -8534,10 +8782,10 @@ public enum SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence Custom, } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8545,21 +8793,21 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + "annual" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual, - "monthly" => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual, + "monthly" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly, - "one_time" => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime, - "custom" => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence)(-1), + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly, + "one_time" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime, + "custom" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence value, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence value, JsonSerializerOptions options ) { @@ -8567,16 +8815,16 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual => "annual", + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly => + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime => + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom => "custom", + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -8587,66 +8835,47 @@ 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( IReadOnlyDictionary rawData ) { @@ -8655,7 +8884,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( FrozenDictionary rawData ) { @@ -8663,8 +8892,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8672,31 +8901,29 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( - string minimumAmount - ) + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig(double percent) : this() { - this.MinimumAmount = minimumAmount; + this.Percent = percent; } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8714,7 +8941,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8723,7 +8950,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8732,7 +8959,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( JsonElement element ) { @@ -8816,7 +9043,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" ); } } @@ -8852,16 +9079,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8880,18 +9107,18 @@ 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 - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8899,13 +9126,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8970,7 +9210,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( element ); } @@ -8979,7 +9219,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -8989,30 +9229,45 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePricePercent, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePricePercent : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput : JsonModel { /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } + /// + /// Configuration for event_output pricing + /// + public required SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig EventOutputConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "event_output_config" + ); + } + init { this._rawData.Set("event_output_config", value); } + } + /// /// The id of the item the price will be associated with. /// @@ -9052,21 +9307,6 @@ public required string Name init { this._rawData.Set("name", value); } } - /// - /// Configuration for percent pricing - /// - public required SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig PercentConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); - } - init { this._rawData.Set("percent_config", value); } - } - /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -9126,12 +9366,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" ); } @@ -9222,6 +9462,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 @@ -9261,13 +9514,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(); @@ -9279,32 +9537,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercent() + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() { - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( - SubscriptionSchedulePlanChangeParamsAddPricePricePercent subscriptionSchedulePlanChangeParamsAddPricePricePercent +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput ) - : base(subscriptionSchedulePlanChangeParamsAddPricePricePercent) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePricePercent( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( FrozenDictionary rawData ) { @@ -9312,8 +9574,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9321,20 +9583,22 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsAddPricePricePercentFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsAddPricePricePercent.FromRawUnchecked(rawData); + ) => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceConverter))] -public enum SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceConverter) +)] +public enum SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence { Annual, SemiAnnual, @@ -9344,10 +9608,10 @@ public enum SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence Custom, } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9355,21 +9619,23 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + "annual" => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual, - "monthly" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual, + "monthly" => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly, - "one_time" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime, - "custom" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence)(-1), - }; - } - + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly, + "one_time" => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime, + "custom" => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence)(-1), + }; + } + public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence value, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence value, JsonSerializerOptions options ) { @@ -9377,16 +9643,18 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual => + "annual", + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom => "custom", + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom => + "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -9397,44 +9665,78 @@ 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig ) - : base(subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( IReadOnlyDictionary rawData ) { @@ -9443,7 +9745,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( FrozenDictionary rawData ) { @@ -9451,8 +9753,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9460,29 +9762,31 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig(double percent) + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( + string unitRatingKey + ) : this() { - this.Percent = percent; + this.UnitRatingKey = unitRatingKey; } } -class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -9500,7 +9804,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9509,7 +9813,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9518,7 +9822,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( JsonElement element ) { @@ -9602,7 +9906,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" ); } } @@ -9638,16 +9942,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -9666,18 +9970,18 @@ 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 - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -9685,13 +9989,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9756,7 +10073,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( element ); } @@ -9765,7 +10082,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -9773,329 +10090,284 @@ 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); } - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( + SubscriptionSchedulePlanChangeParamsRemoveAdjustment subscriptionSchedulePlanChangeParamsRemoveAdjustment + ) + : base(subscriptionSchedulePlanChangeParamsRemoveAdjustment) { } +#pragma warning restore CS8618 - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance + public 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() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsRemovePrice( + SubscriptionSchedulePlanChangeParamsRemovePrice subscriptionSchedulePlanChangeParamsRemovePrice + ) + : base(subscriptionSchedulePlanChangeParamsRemovePrice) { } +#pragma warning restore CS8618 + + 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( + SubscriptionSchedulePlanChangeParamsReplaceAdjustment subscriptionSchedulePlanChangeParamsReplaceAdjustment ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput) { } + : base(subscriptionSchedulePlanChangeParamsReplaceAdjustment) { } +#pragma warning restore CS8618 - 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 ) { @@ -10103,8 +10375,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplaceAdjustment FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -10112,288 +10384,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 - ); -} + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(JsonElement element) + { + this._element = element; + } -[JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigConverter) -)] -public record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig - : ModelBase -{ - public object? Value { get; } = null; - - 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; } @@ -10411,28 +10611,43 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// /// public void Switch( - System::Action unit, - System::Action tiered + System::Action newPercentageDiscount, + System::Action newUsageDiscount, + System::Action newAmountDiscount, + System::Action newMinimum, + System::Action newMaximum ) { switch (this.Value) { - case SharedUnitConversionRateConfig value: - unit(value); + case NewPercentageDiscount value: + newPercentageDiscount(value); break; - case SharedTieredConversionRateConfig value: - tiered(value); + case NewUsageDiscount value: + newUsageDiscount(value); + break; + case NewAmountDiscount value: + newAmountDiscount(value); + break; + case NewMinimum value: + newMinimum(value); + break; + case NewMaximum value: + newMaximum(value); break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" ); } } @@ -10452,33 +10667,54 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// /// public T Match( - System::Func unit, - System::Func tiered + System::Func newPercentageDiscount, + System::Func newUsageDiscount, + System::Func newAmountDiscount, + System::Func newMinimum, + System::Func newMaximum ) { return this.Value switch { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), + NewPercentageDiscount value => newPercentageDiscount(value), + NewUsageDiscount value => newUsageDiscount(value), + NewAmountDiscount value => newAmountDiscount(value), + NewMinimum value => newMinimum(value), + NewMaximum value => newMaximum(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( - SharedUnitConversionRateConfig value + public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewPercentageDiscount value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( - SharedTieredConversionRateConfig value + public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewUsageDiscount value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewAmountDiscount value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewMinimum value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewMaximum value ) => new(value); /// @@ -10496,18 +10732,24 @@ 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 - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -10515,36 +10757,52 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + 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 SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; + string? adjustmentType; try { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + adjustmentType = element.GetProperty("adjustment_type").GetString(); } catch { - conversionRateType = null; + adjustmentType = null; } - switch (conversionRateType) + switch (adjustmentType) { - case "unit": + case "percentage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -10562,11 +10820,11 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "usage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); @@ -10584,176 +10842,233 @@ 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 + } - public override void Write( - Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, 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 + } -/// -/// 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) { } + /// + /// [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 SubscriptionSchedulePlanChangeParamsRemoveAdjustment( - IReadOnlyDictionary 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 disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsRemoveAdjustment( - FrozenDictionary rawData - ) + /// + /// The new quantity of the price, if the price is a fixed price. + /// + public double? FixedPriceQuantity { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } } -#pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsRemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount + /// for the replacement price. + /// + [System::Obsolete("deprecated")] + public string? MaximumAmount { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("maximum_amount"); + } + init { this._rawData.Set("maximum_amount", value); } } - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment(string adjustmentID) - : this() + /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values. + /// + public IReadOnlyDictionary? MetricParameterOverrides { - this.AdjustmentID = adjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(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 { @@ -10768,18 +11083,32 @@ public string? PriceID /// public override void Validate() { - _ = this.ExternalPriceID; + _ = this.ReplacesPriceID; + this.AllocationPrice?.Validate(); + foreach (var item in this.Discounts ?? []) + { + item.Validate(); + } + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; + _ = this.MinimumAmount; + this.Price?.Validate(); _ = this.PriceID; } - public SubscriptionSchedulePlanChangeParamsRemovePrice() { } + public SubscriptionSchedulePlanChangeParamsReplacePrice() { } - public SubscriptionSchedulePlanChangeParamsRemovePrice( - SubscriptionSchedulePlanChangeParamsRemovePrice subscriptionSchedulePlanChangeParamsRemovePrice +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePrice( + SubscriptionSchedulePlanChangeParamsReplacePrice subscriptionSchedulePlanChangeParamsReplacePrice ) - : base(subscriptionSchedulePlanChangeParamsRemovePrice) { } + : base(subscriptionSchedulePlanChangeParamsReplacePrice) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsRemovePrice( + public SubscriptionSchedulePlanChangeParamsReplacePrice( IReadOnlyDictionary rawData ) { @@ -10788,120 +11117,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; @@ -10918,4633 +11169,2893 @@ public JsonElement Json } } - public string? Currency + public string ItemID { get { - return Match( - newPercentageDiscount: (x) => x.Currency, - newUsageDiscount: (x) => x.Currency, - newAmountDiscount: (x) => x.Currency, - newMinimum: (x) => x.Currency, - newMaximum: (x) => x.Currency + return Match( + newSubscriptionUnit: (x) => x.ItemID, + newSubscriptionTiered: (x) => x.ItemID, + newSubscriptionBulk: (x) => x.ItemID, + bulkWithFilters: (x) => x.ItemID, + newSubscriptionPackage: (x) => x.ItemID, + newSubscriptionMatrix: (x) => x.ItemID, + newSubscriptionThresholdTotalAmount: (x) => x.ItemID, + newSubscriptionTieredPackage: (x) => x.ItemID, + newSubscriptionTieredWithMinimum: (x) => x.ItemID, + newSubscriptionGroupedTiered: (x) => x.ItemID, + newSubscriptionTieredPackageWithMinimum: (x) => x.ItemID, + newSubscriptionPackageWithAllocation: (x) => x.ItemID, + newSubscriptionUnitWithPercent: (x) => x.ItemID, + newSubscriptionMatrixWithAllocation: (x) => x.ItemID, + tieredWithProration: (x) => x.ItemID, + newSubscriptionUnitWithProration: (x) => x.ItemID, + newSubscriptionGroupedAllocation: (x) => x.ItemID, + newSubscriptionBulkWithProration: (x) => x.ItemID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ItemID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ItemID, + groupedWithMinMaxThresholds: (x) => x.ItemID, + newSubscriptionMatrixWithDisplayName: (x) => x.ItemID, + newSubscriptionGroupedTieredPackage: (x) => x.ItemID, + newSubscriptionMaxGroupTieredPackage: (x) => x.ItemID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ItemID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ItemID, + newSubscriptionCumulativeGroupedBulk: (x) => x.ItemID, + cumulativeGroupedAllocation: (x) => x.ItemID, + newSubscriptionMinimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID ); } } - public bool? IsInvoiceLevel + public string Name { get { - return Match( - newPercentageDiscount: (x) => x.IsInvoiceLevel, - newUsageDiscount: (x) => x.IsInvoiceLevel, - newAmountDiscount: (x) => x.IsInvoiceLevel, - newMinimum: (x) => x.IsInvoiceLevel, - newMaximum: (x) => x.IsInvoiceLevel + return Match( + newSubscriptionUnit: (x) => x.Name, + newSubscriptionTiered: (x) => x.Name, + newSubscriptionBulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + newSubscriptionPackage: (x) => x.Name, + newSubscriptionMatrix: (x) => x.Name, + newSubscriptionThresholdTotalAmount: (x) => x.Name, + newSubscriptionTieredPackage: (x) => x.Name, + newSubscriptionTieredWithMinimum: (x) => x.Name, + newSubscriptionGroupedTiered: (x) => x.Name, + newSubscriptionTieredPackageWithMinimum: (x) => x.Name, + newSubscriptionPackageWithAllocation: (x) => x.Name, + newSubscriptionUnitWithPercent: (x) => x.Name, + newSubscriptionMatrixWithAllocation: (x) => x.Name, + tieredWithProration: (x) => x.Name, + newSubscriptionUnitWithProration: (x) => x.Name, + newSubscriptionGroupedAllocation: (x) => x.Name, + newSubscriptionBulkWithProration: (x) => x.Name, + newSubscriptionGroupedWithProratedMinimum: (x) => x.Name, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.Name, + groupedWithMinMaxThresholds: (x) => x.Name, + newSubscriptionMatrixWithDisplayName: (x) => x.Name, + newSubscriptionGroupedTieredPackage: (x) => x.Name, + newSubscriptionMaxGroupTieredPackage: (x) => x.Name, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Name, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Name, + newSubscriptionCumulativeGroupedBulk: (x) => x.Name, + cumulativeGroupedAllocation: (x) => x.Name, + newSubscriptionMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name ); } } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewPercentageDiscount value, - JsonElement? element = null - ) + public string? BillableMetricID { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.BillableMetricID, + newSubscriptionTiered: (x) => x.BillableMetricID, + newSubscriptionBulk: (x) => x.BillableMetricID, + bulkWithFilters: (x) => x.BillableMetricID, + newSubscriptionPackage: (x) => x.BillableMetricID, + newSubscriptionMatrix: (x) => x.BillableMetricID, + newSubscriptionThresholdTotalAmount: (x) => x.BillableMetricID, + newSubscriptionTieredPackage: (x) => x.BillableMetricID, + newSubscriptionTieredWithMinimum: (x) => x.BillableMetricID, + newSubscriptionGroupedTiered: (x) => x.BillableMetricID, + newSubscriptionTieredPackageWithMinimum: (x) => x.BillableMetricID, + newSubscriptionPackageWithAllocation: (x) => x.BillableMetricID, + newSubscriptionUnitWithPercent: (x) => x.BillableMetricID, + newSubscriptionMatrixWithAllocation: (x) => x.BillableMetricID, + tieredWithProration: (x) => x.BillableMetricID, + newSubscriptionUnitWithProration: (x) => x.BillableMetricID, + newSubscriptionGroupedAllocation: (x) => x.BillableMetricID, + newSubscriptionBulkWithProration: (x) => x.BillableMetricID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BillableMetricID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillableMetricID, + groupedWithMinMaxThresholds: (x) => x.BillableMetricID, + newSubscriptionMatrixWithDisplayName: (x) => x.BillableMetricID, + newSubscriptionGroupedTieredPackage: (x) => x.BillableMetricID, + newSubscriptionMaxGroupTieredPackage: (x) => x.BillableMetricID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, + newSubscriptionCumulativeGroupedBulk: (x) => x.BillableMetricID, + cumulativeGroupedAllocation: (x) => x.BillableMetricID, + newSubscriptionMinimumComposite: (x) => x.BillableMetricID, + percent: (x) => x.BillableMetricID, + eventOutput: (x) => x.BillableMetricID + ); + } } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewUsageDiscount value, - JsonElement? element = null - ) + public bool? BilledInAdvance { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewAmountDiscount value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.BilledInAdvance, + newSubscriptionTiered: (x) => x.BilledInAdvance, + newSubscriptionBulk: (x) => x.BilledInAdvance, + bulkWithFilters: (x) => x.BilledInAdvance, + newSubscriptionPackage: (x) => x.BilledInAdvance, + newSubscriptionMatrix: (x) => x.BilledInAdvance, + newSubscriptionThresholdTotalAmount: (x) => x.BilledInAdvance, + newSubscriptionTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionTieredWithMinimum: (x) => x.BilledInAdvance, + newSubscriptionGroupedTiered: (x) => x.BilledInAdvance, + newSubscriptionTieredPackageWithMinimum: (x) => x.BilledInAdvance, + newSubscriptionPackageWithAllocation: (x) => x.BilledInAdvance, + newSubscriptionUnitWithPercent: (x) => x.BilledInAdvance, + newSubscriptionMatrixWithAllocation: (x) => x.BilledInAdvance, + tieredWithProration: (x) => x.BilledInAdvance, + newSubscriptionUnitWithProration: (x) => x.BilledInAdvance, + newSubscriptionGroupedAllocation: (x) => x.BilledInAdvance, + newSubscriptionBulkWithProration: (x) => x.BilledInAdvance, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BilledInAdvance, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, + groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, + newSubscriptionMatrixWithDisplayName: (x) => x.BilledInAdvance, + newSubscriptionGroupedTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionMaxGroupTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, + newSubscriptionCumulativeGroupedBulk: (x) => x.BilledInAdvance, + cumulativeGroupedAllocation: (x) => x.BilledInAdvance, + newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); + } } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMinimum value, - JsonElement? element = null - ) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.BillingCycleConfiguration, + newSubscriptionTiered: (x) => x.BillingCycleConfiguration, + newSubscriptionBulk: (x) => x.BillingCycleConfiguration, + bulkWithFilters: (x) => x.BillingCycleConfiguration, + newSubscriptionPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrix: (x) => x.BillingCycleConfiguration, + newSubscriptionThresholdTotalAmount: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredWithMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedTiered: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionPackageWithAllocation: (x) => x.BillingCycleConfiguration, + newSubscriptionUnitWithPercent: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrixWithAllocation: (x) => x.BillingCycleConfiguration, + tieredWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionUnitWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedAllocation: (x) => x.BillingCycleConfiguration, + newSubscriptionBulkWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, + newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, + newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, + percent: (x) => x.BillingCycleConfiguration, + eventOutput: (x) => x.BillingCycleConfiguration + ); + } } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMaximum value, - JsonElement? element = null - ) + public double? ConversionRate { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.ConversionRate, + newSubscriptionTiered: (x) => x.ConversionRate, + newSubscriptionBulk: (x) => x.ConversionRate, + bulkWithFilters: (x) => x.ConversionRate, + newSubscriptionPackage: (x) => x.ConversionRate, + newSubscriptionMatrix: (x) => x.ConversionRate, + newSubscriptionThresholdTotalAmount: (x) => x.ConversionRate, + newSubscriptionTieredPackage: (x) => x.ConversionRate, + newSubscriptionTieredWithMinimum: (x) => x.ConversionRate, + newSubscriptionGroupedTiered: (x) => x.ConversionRate, + newSubscriptionTieredPackageWithMinimum: (x) => x.ConversionRate, + newSubscriptionPackageWithAllocation: (x) => x.ConversionRate, + newSubscriptionUnitWithPercent: (x) => x.ConversionRate, + newSubscriptionMatrixWithAllocation: (x) => x.ConversionRate, + tieredWithProration: (x) => x.ConversionRate, + newSubscriptionUnitWithProration: (x) => x.ConversionRate, + newSubscriptionGroupedAllocation: (x) => x.ConversionRate, + newSubscriptionBulkWithProration: (x) => x.ConversionRate, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ConversionRate, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ConversionRate, + groupedWithMinMaxThresholds: (x) => x.ConversionRate, + newSubscriptionMatrixWithDisplayName: (x) => x.ConversionRate, + newSubscriptionGroupedTieredPackage: (x) => x.ConversionRate, + newSubscriptionMaxGroupTieredPackage: (x) => x.ConversionRate, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ConversionRate, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ConversionRate, + newSubscriptionCumulativeGroupedBulk: (x) => x.ConversionRate, + cumulativeGroupedAllocation: (x) => x.ConversionRate, + newSubscriptionMinimumComposite: (x) => x.ConversionRate, + percent: (x) => x.ConversionRate, + eventOutput: (x) => x.ConversionRate + ); + } } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(JsonElement element) + public string? Currency { - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.Currency, + newSubscriptionTiered: (x) => x.Currency, + newSubscriptionBulk: (x) => x.Currency, + bulkWithFilters: (x) => x.Currency, + newSubscriptionPackage: (x) => x.Currency, + newSubscriptionMatrix: (x) => x.Currency, + newSubscriptionThresholdTotalAmount: (x) => x.Currency, + newSubscriptionTieredPackage: (x) => x.Currency, + newSubscriptionTieredWithMinimum: (x) => x.Currency, + newSubscriptionGroupedTiered: (x) => x.Currency, + newSubscriptionTieredPackageWithMinimum: (x) => x.Currency, + newSubscriptionPackageWithAllocation: (x) => x.Currency, + newSubscriptionUnitWithPercent: (x) => x.Currency, + newSubscriptionMatrixWithAllocation: (x) => x.Currency, + tieredWithProration: (x) => x.Currency, + newSubscriptionUnitWithProration: (x) => x.Currency, + newSubscriptionGroupedAllocation: (x) => x.Currency, + newSubscriptionBulkWithProration: (x) => x.Currency, + newSubscriptionGroupedWithProratedMinimum: (x) => x.Currency, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.Currency, + groupedWithMinMaxThresholds: (x) => x.Currency, + newSubscriptionMatrixWithDisplayName: (x) => x.Currency, + newSubscriptionGroupedTieredPackage: (x) => x.Currency, + newSubscriptionMaxGroupTieredPackage: (x) => x.Currency, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Currency, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Currency, + newSubscriptionCumulativeGroupedBulk: (x) => x.Currency, + cumulativeGroupedAllocation: (x) => x.Currency, + newSubscriptionMinimumComposite: (x) => x.Currency, + percent: (x) => x.Currency, + eventOutput: (x) => x.Currency + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPercentageDiscount(out var value)) { - /// // `value` is of type `NewPercentageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - value = this.Value as NewPercentageDiscount; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.DimensionalPriceConfiguration, + newSubscriptionTiered: (x) => x.DimensionalPriceConfiguration, + newSubscriptionBulk: (x) => x.DimensionalPriceConfiguration, + bulkWithFilters: (x) => x.DimensionalPriceConfiguration, + newSubscriptionPackage: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMatrix: (x) => x.DimensionalPriceConfiguration, + newSubscriptionThresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, + newSubscriptionTieredPackage: (x) => x.DimensionalPriceConfiguration, + newSubscriptionTieredWithMinimum: (x) => x.DimensionalPriceConfiguration, + newSubscriptionGroupedTiered: (x) => x.DimensionalPriceConfiguration, + newSubscriptionTieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, + newSubscriptionPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, + newSubscriptionUnitWithPercent: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, + tieredWithProration: (x) => x.DimensionalPriceConfiguration, + newSubscriptionUnitWithProration: (x) => x.DimensionalPriceConfiguration, + newSubscriptionGroupedAllocation: (x) => x.DimensionalPriceConfiguration, + newSubscriptionBulkWithProration: (x) => x.DimensionalPriceConfiguration, + newSubscriptionGroupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.DimensionalPriceConfiguration, + groupedWithMinMaxThresholds: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMatrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, + newSubscriptionGroupedTieredPackage: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMaxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, + newSubscriptionScalableMatrixWithUnitPricing: (x) => + x.DimensionalPriceConfiguration, + newSubscriptionScalableMatrixWithTieredPricing: (x) => + x.DimensionalPriceConfiguration, + newSubscriptionCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, + cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + public string? ExternalPriceID { - value = this.Value as NewUsageDiscount; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewAmountDiscount(out var value)) { - /// // `value` is of type `NewAmountDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + 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 + ); + } + } + + public double? FixedPriceQuantity { - value = this.Value as NewAmountDiscount; - 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.TryPickNewMinimum(out var value)) { - /// // `value` is of type `NewMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) + public string? InvoiceGroupingKey { - value = this.Value as NewMinimum; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.InvoiceGroupingKey, + newSubscriptionTiered: (x) => x.InvoiceGroupingKey, + newSubscriptionBulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + newSubscriptionPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrix: (x) => x.InvoiceGroupingKey, + newSubscriptionThresholdTotalAmount: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredWithMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedTiered: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionPackageWithAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionUnitWithPercent: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + tieredWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionUnitWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionBulkWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, + newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, + cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewMaximum(out var value)) { - /// // `value` is of type `NewMaximum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - value = this.Value as NewMaximum; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTiered: (x) => x.InvoicingCycleConfiguration, + newSubscriptionBulk: (x) => x.InvoicingCycleConfiguration, + bulkWithFilters: (x) => x.InvoicingCycleConfiguration, + newSubscriptionPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrix: (x) => x.InvoicingCycleConfiguration, + newSubscriptionThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedTiered: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, + newSubscriptionUnitWithPercent: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + tieredWithProration: (x) => x.InvoicingCycleConfiguration, + newSubscriptionUnitWithProration: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + newSubscriptionBulkWithProration: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, + newSubscriptionScalableMatrixWithTieredPricing: (x) => + x.InvoicingCycleConfiguration, + newSubscriptionCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMinimumComposite: (x) => x.InvoicingCycleConfiguration, + percent: (x) => x.InvoicingCycleConfiguration, + eventOutput: (x) => x.InvoicingCycleConfiguration + ); + } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action newPercentageDiscount, - System::Action newUsageDiscount, - System::Action newAmountDiscount, - System::Action newMinimum, - System::Action newMaximum - ) + public string? LicenseTypeID { - 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.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 + ); } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func newPercentageDiscount, - System::Func newUsageDiscount, - System::Func newAmountDiscount, - System::Func newMinimum, - System::Func newMaximum - ) + public string? ReferenceID { - return this.Value switch + get { - NewPercentageDiscount value => newPercentageDiscount(value), - NewUsageDiscount value => newUsageDiscount(value), - NewAmountDiscount value => newAmountDiscount(value), - NewMinimum value => newMinimum(value), - NewMaximum value => newMaximum(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" - ), - }; + return Match( + newSubscriptionUnit: (x) => x.ReferenceID, + newSubscriptionTiered: (x) => x.ReferenceID, + newSubscriptionBulk: (x) => x.ReferenceID, + bulkWithFilters: (x) => x.ReferenceID, + newSubscriptionPackage: (x) => x.ReferenceID, + newSubscriptionMatrix: (x) => x.ReferenceID, + newSubscriptionThresholdTotalAmount: (x) => x.ReferenceID, + newSubscriptionTieredPackage: (x) => x.ReferenceID, + newSubscriptionTieredWithMinimum: (x) => x.ReferenceID, + newSubscriptionGroupedTiered: (x) => x.ReferenceID, + newSubscriptionTieredPackageWithMinimum: (x) => x.ReferenceID, + newSubscriptionPackageWithAllocation: (x) => x.ReferenceID, + newSubscriptionUnitWithPercent: (x) => x.ReferenceID, + newSubscriptionMatrixWithAllocation: (x) => x.ReferenceID, + tieredWithProration: (x) => x.ReferenceID, + newSubscriptionUnitWithProration: (x) => x.ReferenceID, + newSubscriptionGroupedAllocation: (x) => x.ReferenceID, + newSubscriptionBulkWithProration: (x) => x.ReferenceID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ReferenceID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ReferenceID, + groupedWithMinMaxThresholds: (x) => x.ReferenceID, + newSubscriptionMatrixWithDisplayName: (x) => x.ReferenceID, + newSubscriptionGroupedTieredPackage: (x) => x.ReferenceID, + newSubscriptionMaxGroupTieredPackage: (x) => x.ReferenceID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ReferenceID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, + newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, + cumulativeGroupedAllocation: (x) => x.ReferenceID, + newSubscriptionMinimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID + ); + } } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewPercentageDiscount value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewUsageDiscount value - ) => new(value); + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewAmountDiscount value - ) => new(value); + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMinimum value - ) => new(value); + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionBulkPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMaximum value - ) => new(value); + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionPackagePrice value, + JsonElement? element = null + ) { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" - ); - } - this.Switch( - (newPercentageDiscount) => newPercentageDiscount.Validate(), - (newUsageDiscount) => newUsageDiscount.Validate(), - (newAmountDiscount) => newAmountDiscount.Validate(), - (newMinimum) => newMinimum.Validate(), - (newMaximum) => newMaximum.Validate() - ); + this.Value = value; + this._element = element; } - public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? other + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixPrice value, + JsonElement? element = null ) { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + this.Value = value; + this._element = element; } - public override int GetHashCode() + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionThresholdTotalAmountPrice value, + JsonElement? element = null + ) { - return 0; + this.Value = value; + this._element = element; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPackagePrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } -sealed class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentConverter - : JsonConverter -{ - public override SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredWithMinimumPrice value, + JsonElement? element = null ) { - var element = JsonSerializer.Deserialize(ref reader, options); - string? adjustmentType; - try - { - adjustmentType = element.GetProperty("adjustment_type").GetString(); - } - catch - { - adjustmentType = null; - } + this.Value = value; + this._element = element; + } - switch (adjustmentType) - { - case "percentage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedTieredPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "usage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPackageWithMinimumPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "amount_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "maximum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(element); - } - } + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionPackageWithAllocationPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; } - public override void Write( - Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value, - JsonSerializerOptions options + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitWithPercentPrice value, + JsonElement? element = null ) { - JsonSerializer.Serialize(writer, value.Json, options); + this.Value = value; + this._element = element; } -} -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePrice, - SubscriptionSchedulePlanChangeParamsReplacePriceFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePrice : JsonModel -{ - /// - /// The id of the price on the plan to replace in the subscription. - /// - public required string ReplacesPriceID + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixWithAllocationPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_price_id"); - } - init { this._rawData.Set("replaces_price_id", value); } + this.Value = value; + this._element = element; } - /// - /// The definition of a new allocation price to create and add to the subscription. - /// - public NewAllocationPrice? AllocationPrice + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("allocation_price"); - } - init { this._rawData.Set("allocation_price", value); } + this.Value = value; + this._element = element; } - /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for - /// the replacement price. - /// - [System::Obsolete("deprecated")] - public IReadOnlyList? Discounts + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitWithProrationPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct>("discounts"); - } - init - { - this._rawData.Set?>( - "discounts", - value == null ? null : ImmutableArray.ToImmutableArray(value) - ); - } + this.Value = value; + this._element = element; } - /// - /// The external price id of the price to add to the subscription. - /// - public string? ExternalPriceID + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedAllocationPrice 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( + NewSubscriptionBulkWithProrationPrice 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( + NewSubscriptionGroupedWithProratedMinimumPrice 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( + NewSubscriptionGroupedWithMeteredMinimumPrice 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( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds 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( + NewSubscriptionMatrixWithDisplayNamePrice 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() - { - _ = 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedTieredPackagePrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePrice() { } - - public SubscriptionSchedulePlanChangeParamsReplacePrice( - SubscriptionSchedulePlanChangeParamsReplacePrice subscriptionSchedulePlanChangeParamsReplacePrice + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMaxGroupTieredPackagePrice value, + JsonElement? element = null ) - : base(subscriptionSchedulePlanChangeParamsReplacePrice) { } + { + this.Value = value; + this._element = element; + } - public SubscriptionSchedulePlanChangeParamsReplacePrice( - IReadOnlyDictionary rawData + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionScalableMatrixWithUnitPricingPrice value, + JsonElement? element = null ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePrice(FrozenDictionary rawData) + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionScalableMatrixWithTieredPricingPrice 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( + NewSubscriptionCumulativeGroupedBulkPrice value, + JsonElement? element = null ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsReplacePrice(string replacesPriceID) - : this() + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value, + JsonElement? element = null + ) { - this.ReplacesPriceID = replacesPriceID; + this.Value = value; + this._element = element; } -} - -class SubscriptionSchedulePlanChangeParamsReplacePriceFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsReplacePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsReplacePrice.FromRawUnchecked(rawData); -} - -/// -/// New subscription price request body params. -/// -[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter))] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePrice : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - public JsonElement Json + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMinimumCompositePrice 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( + SubscriptionSchedulePlanChangeParamsReplacePricePricePercent 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( + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput 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(JsonElement 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, - minimum: (x) => x.BillableMetricID, - newSubscriptionMinimumComposite: (x) => x.BillableMetricID, - percent: (x) => x.BillableMetricID, - eventOutput: (x) => x.BillableMetricID - ); - } + this._element = element; } - 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.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.BilledInAdvance, - newSubscriptionTiered: (x) => x.BilledInAdvance, - newSubscriptionBulk: (x) => x.BilledInAdvance, - bulkWithFilters: (x) => x.BilledInAdvance, - newSubscriptionPackage: (x) => x.BilledInAdvance, - newSubscriptionMatrix: (x) => x.BilledInAdvance, - newSubscriptionThresholdTotalAmount: (x) => x.BilledInAdvance, - newSubscriptionTieredPackage: (x) => x.BilledInAdvance, - newSubscriptionTieredWithMinimum: (x) => x.BilledInAdvance, - newSubscriptionGroupedTiered: (x) => x.BilledInAdvance, - newSubscriptionTieredPackageWithMinimum: (x) => x.BilledInAdvance, - newSubscriptionPackageWithAllocation: (x) => x.BilledInAdvance, - newSubscriptionUnitWithPercent: (x) => x.BilledInAdvance, - newSubscriptionMatrixWithAllocation: (x) => x.BilledInAdvance, - tieredWithProration: (x) => x.BilledInAdvance, - newSubscriptionUnitWithProration: (x) => x.BilledInAdvance, - newSubscriptionGroupedAllocation: (x) => x.BilledInAdvance, - newSubscriptionBulkWithProration: (x) => x.BilledInAdvance, - newSubscriptionGroupedWithProratedMinimum: (x) => x.BilledInAdvance, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, - groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, - newSubscriptionMatrixWithDisplayName: (x) => x.BilledInAdvance, - newSubscriptionGroupedTieredPackage: (x) => x.BilledInAdvance, - newSubscriptionMaxGroupTieredPackage: (x) => x.BilledInAdvance, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, - newSubscriptionCumulativeGroupedBulk: (x) => x.BilledInAdvance, - cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, - newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, - percent: (x) => x.BilledInAdvance, - eventOutput: (x) => x.BilledInAdvance - ); - } + value = this.Value as NewSubscriptionUnitPrice; + 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.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.BillingCycleConfiguration, - newSubscriptionTiered: (x) => x.BillingCycleConfiguration, - newSubscriptionBulk: (x) => x.BillingCycleConfiguration, - bulkWithFilters: (x) => x.BillingCycleConfiguration, - newSubscriptionPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionMatrix: (x) => x.BillingCycleConfiguration, - newSubscriptionThresholdTotalAmount: (x) => x.BillingCycleConfiguration, - newSubscriptionTieredPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionTieredWithMinimum: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedTiered: (x) => x.BillingCycleConfiguration, - newSubscriptionTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, - newSubscriptionPackageWithAllocation: (x) => x.BillingCycleConfiguration, - newSubscriptionUnitWithPercent: (x) => x.BillingCycleConfiguration, - newSubscriptionMatrixWithAllocation: (x) => x.BillingCycleConfiguration, - tieredWithProration: (x) => x.BillingCycleConfiguration, - newSubscriptionUnitWithProration: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedAllocation: (x) => x.BillingCycleConfiguration, - newSubscriptionBulkWithProration: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, - newSubscriptionMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedTieredPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, - newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, - newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, - percent: (x) => x.BillingCycleConfiguration, - eventOutput: (x) => x.BillingCycleConfiguration - ); - } + value = this.Value as NewSubscriptionTieredPrice; + 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.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.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 NewSubscriptionBulkPrice; + 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.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters; + 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.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.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 NewSubscriptionPackagePrice; + return value != null; } - public string? ExternalPriceID - { - 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 - ); - } + /// + /// Returns true and sets the 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 + ) + { + value = this.Value as NewSubscriptionMatrixPrice; + 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.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.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 NewSubscriptionThresholdTotalAmountPrice; + 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.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.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 NewSubscriptionTieredPackagePrice; + 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.TryPickNewSubscriptionTieredWithMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTieredWithMinimum( + [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.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 NewSubscriptionTieredWithMinimumPrice; + 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.TryPickNewSubscriptionGroupedTiered(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionGroupedTiered( + [NotNullWhen(true)] out NewSubscriptionGroupedTieredPrice? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.ReferenceID, - newSubscriptionTiered: (x) => x.ReferenceID, - newSubscriptionBulk: (x) => x.ReferenceID, - bulkWithFilters: (x) => x.ReferenceID, - newSubscriptionPackage: (x) => x.ReferenceID, - newSubscriptionMatrix: (x) => x.ReferenceID, - newSubscriptionThresholdTotalAmount: (x) => x.ReferenceID, - newSubscriptionTieredPackage: (x) => x.ReferenceID, - newSubscriptionTieredWithMinimum: (x) => x.ReferenceID, - newSubscriptionGroupedTiered: (x) => x.ReferenceID, - newSubscriptionTieredPackageWithMinimum: (x) => x.ReferenceID, - newSubscriptionPackageWithAllocation: (x) => x.ReferenceID, - newSubscriptionUnitWithPercent: (x) => x.ReferenceID, - newSubscriptionMatrixWithAllocation: (x) => x.ReferenceID, - tieredWithProration: (x) => x.ReferenceID, - newSubscriptionUnitWithProration: (x) => x.ReferenceID, - newSubscriptionGroupedAllocation: (x) => x.ReferenceID, - newSubscriptionBulkWithProration: (x) => x.ReferenceID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ReferenceID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ReferenceID, - groupedWithMinMaxThresholds: (x) => x.ReferenceID, - newSubscriptionMatrixWithDisplayName: (x) => x.ReferenceID, - newSubscriptionGroupedTieredPackage: (x) => x.ReferenceID, - newSubscriptionMaxGroupTieredPackage: (x) => x.ReferenceID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ReferenceID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, - newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, - cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, - newSubscriptionMinimumComposite: (x) => x.ReferenceID, - percent: (x) => x.ReferenceID, - eventOutput: (x) => x.ReferenceID - ); - } + value = this.Value as NewSubscriptionGroupedTieredPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitPrice value, - JsonElement? element = null + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPrice value, - JsonElement? element = null + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionPackageWithAllocation(out var value)) { + /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionPackageWithAllocation( + [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionPackageWithAllocationPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - 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.TryPickNewSubscriptionUnitWithPercent(out var value)) { + /// // `value` is of type `NewSubscriptionUnitWithPercentPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionUnitWithPercent( + [NotNullWhen(true)] out NewSubscriptionUnitWithPercentPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionUnitWithPercentPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value, - JsonElement? element = null + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionMatrixWithAllocation(out var value)) { + /// // `value` is of type `NewSubscriptionMatrixWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionMatrixWithAllocation( + [NotNullWhen(true)] out NewSubscriptionMatrixWithAllocationPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionMatrixWithAllocationPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - 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.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration? value ) { - this.Value = value; - this._element = element; + value = + this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - 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.TryPickNewSubscriptionUnitWithProration(out var value)) { + /// // `value` is of type `NewSubscriptionUnitWithProrationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionUnitWithProration( + [NotNullWhen(true)] out NewSubscriptionUnitWithProrationPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionUnitWithProrationPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - 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.TryPickNewSubscriptionGroupedAllocation(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionGroupedAllocation( + [NotNullWhen(true)] out NewSubscriptionGroupedAllocationPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionGroupedAllocationPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - 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.TryPickNewSubscriptionBulkWithProration(out var value)) { + /// // `value` is of type `NewSubscriptionBulkWithProrationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionBulkWithProration( + [NotNullWhen(true)] out NewSubscriptionBulkWithProrationPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionBulkWithProrationPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - 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.TryPickNewSubscriptionGroupedWithProratedMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedWithProratedMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionGroupedWithProratedMinimum( + [NotNullWhen(true)] out NewSubscriptionGroupedWithProratedMinimumPrice? value ) { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitWithPercentPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixWithAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMaxGroupTieredPackagePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMinimumCompositePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePrice(JsonElement element) - { - this._element = element; + value = this.Value as 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.TryPickNewSubscriptionUnit(out var value)) { - /// // `value` is of type `NewSubscriptionUnitPrice` + /// if (instance.TryPickNewSubscriptionGroupedWithMeteredMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedWithMeteredMinimumPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUnitPrice? value) + public bool TryPickNewSubscriptionGroupedWithMeteredMinimum( + [NotNullWhen(true)] out NewSubscriptionGroupedWithMeteredMinimumPrice? value + ) { - value = this.Value as NewSubscriptionUnitPrice; + 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.TryPickNewSubscriptionTiered(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPrice` + /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTiered( - [NotNullWhen(true)] out NewSubscriptionTieredPrice? value + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds? value ) { - value = this.Value as NewSubscriptionTieredPrice; + value = + this.Value + as SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionBulk(out var value)) { - /// // `value` is of type `NewSubscriptionBulkPrice` + /// if (instance.TryPickNewSubscriptionMatrixWithDisplayName(out var value)) { + /// // `value` is of type `NewSubscriptionMatrixWithDisplayNamePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionBulk([NotNullWhen(true)] out NewSubscriptionBulkPrice? value) + public bool TryPickNewSubscriptionMatrixWithDisplayName( + [NotNullWhen(true)] out NewSubscriptionMatrixWithDisplayNamePrice? value + ) { - value = this.Value as NewSubscriptionBulkPrice; + 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.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters` + /// if (instance.TryPickNewSubscriptionGroupedTieredPackage(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedTieredPackagePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters? value + public bool TryPickNewSubscriptionGroupedTieredPackage( + [NotNullWhen(true)] out NewSubscriptionGroupedTieredPackagePrice? value ) { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters; + 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 . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionPackage(out var value)) { - /// // `value` is of type `NewSubscriptionPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionPackage( - [NotNullWhen(true)] out NewSubscriptionPackagePrice? value - ) - { - value = this.Value as NewSubscriptionPackagePrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMatrix(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMatrix( - [NotNullWhen(true)] out NewSubscriptionMatrixPrice? value - ) - { - 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 . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackagePrice` + /// if (instance.TryPickNewSubscriptionMaxGroupTieredPackage(out var value)) { + /// // `value` is of type `NewSubscriptionMaxGroupTieredPackagePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTieredPackage( - [NotNullWhen(true)] out NewSubscriptionTieredPackagePrice? value + public bool TryPickNewSubscriptionMaxGroupTieredPackage( + [NotNullWhen(true)] out NewSubscriptionMaxGroupTieredPackagePrice? value ) { - value = this.Value as NewSubscriptionTieredPackagePrice; + 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.TryPickNewSubscriptionTieredWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` + /// if (instance.TryPickNewSubscriptionScalableMatrixWithUnitPricing(out var value)) { + /// // `value` is of type `NewSubscriptionScalableMatrixWithUnitPricingPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTieredWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value + public bool TryPickNewSubscriptionScalableMatrixWithUnitPricing( + [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithUnitPricingPrice? value ) { - value = this.Value as NewSubscriptionTieredWithMinimumPrice; + 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.TryPickNewSubscriptionGroupedTiered(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedTieredPrice` + /// if (instance.TryPickNewSubscriptionScalableMatrixWithTieredPricing(out var value)) { + /// // `value` is of type `NewSubscriptionScalableMatrixWithTieredPricingPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionGroupedTiered( - [NotNullWhen(true)] out NewSubscriptionGroupedTieredPrice? value + public bool TryPickNewSubscriptionScalableMatrixWithTieredPricing( + [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithTieredPricingPrice? value ) { - value = this.Value as NewSubscriptionGroupedTieredPrice; + 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.TryPickNewSubscriptionTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackageWithMinimumPrice` + /// if (instance.TryPickNewSubscriptionCumulativeGroupedBulk(out var value)) { + /// // `value` is of type `NewSubscriptionCumulativeGroupedBulkPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTieredPackageWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredPackageWithMinimumPrice? value + public bool TryPickNewSubscriptionCumulativeGroupedBulk( + [NotNullWhen(true)] out NewSubscriptionCumulativeGroupedBulkPrice? value ) { - value = this.Value as NewSubscriptionTieredPackageWithMinimumPrice; + 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.TryPickNewSubscriptionPackageWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` + /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionPackageWithAllocation( - [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation? value ) { - value = this.Value as NewSubscriptionPackageWithAllocationPrice; + value = + this.Value + as SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionUnitWithPercent(out var value)) { - /// // `value` is of type `NewSubscriptionUnitWithPercentPrice` + /// if (instance.TryPickNewSubscriptionMinimumComposite(out var value)) { + /// // `value` is of type `NewSubscriptionMinimumCompositePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionUnitWithPercent( - [NotNullWhen(true)] out NewSubscriptionUnitWithPercentPrice? value + public bool TryPickNewSubscriptionMinimumComposite( + [NotNullWhen(true)] out NewSubscriptionMinimumCompositePrice? value ) { - value = this.Value as NewSubscriptionUnitWithPercentPrice; + 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.TryPickNewSubscriptionMatrixWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithAllocationPrice` + /// if (instance.TryPickPercent(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePricePercent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionMatrixWithAllocation( - [NotNullWhen(true)] out NewSubscriptionMatrixWithAllocationPrice? value + public bool TryPickPercent( + [NotNullWhen(true)] out SubscriptionSchedulePlanChangeParamsReplacePricePricePercent? value ) { - value = this.Value as NewSubscriptionMatrixWithAllocationPrice; + value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePricePercent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration` + /// if (instance.TryPickEventOutput(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTieredWithProration( + public bool TryPickEventOutput( [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration? value + out SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput? value ) { - value = - this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration; + value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput; return value != null; } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// 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.TryPickNewSubscriptionUnitWithProration(out var value)) { - /// // `value` is of type `NewSubscriptionUnitWithProrationPrice` - /// Console.WriteLine(value); - /// } + /// instance.Switch( + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value) => {...}, + /// (NewSubscriptionUnitWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedAllocationPrice value) => {...}, + /// (NewSubscriptionBulkWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, + /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, + /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value) => {...} + /// ); /// /// /// - public bool TryPickNewSubscriptionUnitWithProration( - [NotNullWhen(true)] out NewSubscriptionUnitWithProrationPrice? 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 NewSubscriptionUnitWithProrationPrice; - return value != null; - } - - /// - /// Returns true and sets the 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 - ) - { - value = this.Value as NewSubscriptionGroupedAllocationPrice; - return value != null; + switch (this.Value) + { + case NewSubscriptionUnitPrice value: + newSubscriptionUnit(value); + break; + case NewSubscriptionTieredPrice value: + newSubscriptionTiered(value); + break; + case NewSubscriptionBulkPrice value: + newSubscriptionBulk(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value: + bulkWithFilters(value); + break; + case NewSubscriptionPackagePrice value: + newSubscriptionPackage(value); + break; + case NewSubscriptionMatrixPrice value: + newSubscriptionMatrix(value); + break; + case NewSubscriptionThresholdTotalAmountPrice value: + newSubscriptionThresholdTotalAmount(value); + break; + case NewSubscriptionTieredPackagePrice value: + newSubscriptionTieredPackage(value); + break; + case NewSubscriptionTieredWithMinimumPrice value: + newSubscriptionTieredWithMinimum(value); + break; + case NewSubscriptionGroupedTieredPrice value: + newSubscriptionGroupedTiered(value); + break; + case NewSubscriptionTieredPackageWithMinimumPrice value: + newSubscriptionTieredPackageWithMinimum(value); + break; + case NewSubscriptionPackageWithAllocationPrice value: + newSubscriptionPackageWithAllocation(value); + break; + case NewSubscriptionUnitWithPercentPrice value: + newSubscriptionUnitWithPercent(value); + break; + case NewSubscriptionMatrixWithAllocationPrice value: + newSubscriptionMatrixWithAllocation(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value: + tieredWithProration(value); + break; + case NewSubscriptionUnitWithProrationPrice value: + newSubscriptionUnitWithProration(value); + break; + case NewSubscriptionGroupedAllocationPrice value: + newSubscriptionGroupedAllocation(value); + break; + case NewSubscriptionBulkWithProrationPrice value: + newSubscriptionBulkWithProration(value); + break; + case NewSubscriptionGroupedWithProratedMinimumPrice value: + newSubscriptionGroupedWithProratedMinimum(value); + break; + case NewSubscriptionGroupedWithMeteredMinimumPrice value: + newSubscriptionGroupedWithMeteredMinimum(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value: + groupedWithMinMaxThresholds(value); + break; + case NewSubscriptionMatrixWithDisplayNamePrice value: + newSubscriptionMatrixWithDisplayName(value); + break; + case NewSubscriptionGroupedTieredPackagePrice value: + newSubscriptionGroupedTieredPackage(value); + break; + case NewSubscriptionMaxGroupTieredPackagePrice value: + newSubscriptionMaxGroupTieredPackage(value); + break; + case NewSubscriptionScalableMatrixWithUnitPricingPrice value: + newSubscriptionScalableMatrixWithUnitPricing(value); + break; + case NewSubscriptionScalableMatrixWithTieredPricingPrice value: + newSubscriptionScalableMatrixWithTieredPricing(value); + break; + case NewSubscriptionCumulativeGroupedBulkPrice value: + newSubscriptionCumulativeGroupedBulk(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case NewSubscriptionMinimumCompositePrice value: + newSubscriptionMinimumComposite(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value: + percent(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value: + eventOutput(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" + ); + } } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. /// - /// Consider using or if you need to handle every variant. + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// /// /// /// - /// if (instance.TryPickNewSubscriptionBulkWithProration(out var value)) { - /// // `value` is of type `NewSubscriptionBulkWithProrationPrice` - /// Console.WriteLine(value); - /// } + /// var result = instance.Match( + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value) => {...}, + /// (NewSubscriptionUnitWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedAllocationPrice value) => {...}, + /// (NewSubscriptionBulkWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, + /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, + /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value) => {...} + /// ); /// /// /// - public bool TryPickNewSubscriptionBulkWithProration( - [NotNullWhen(true)] out NewSubscriptionBulkWithProrationPrice? value + public T Match( + System::Func newSubscriptionUnit, + System::Func newSubscriptionTiered, + System::Func newSubscriptionBulk, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters, + T + > bulkWithFilters, + System::Func newSubscriptionPackage, + System::Func newSubscriptionMatrix, + System::Func< + NewSubscriptionThresholdTotalAmountPrice, + T + > newSubscriptionThresholdTotalAmount, + System::Func newSubscriptionTieredPackage, + System::Func newSubscriptionTieredWithMinimum, + System::Func newSubscriptionGroupedTiered, + System::Func< + NewSubscriptionTieredPackageWithMinimumPrice, + T + > newSubscriptionTieredPackageWithMinimum, + System::Func< + NewSubscriptionPackageWithAllocationPrice, + T + > newSubscriptionPackageWithAllocation, + System::Func newSubscriptionUnitWithPercent, + System::Func< + NewSubscriptionMatrixWithAllocationPrice, + T + > newSubscriptionMatrixWithAllocation, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration, + T + > tieredWithProration, + System::Func newSubscriptionUnitWithProration, + System::Func newSubscriptionGroupedAllocation, + System::Func newSubscriptionBulkWithProration, + System::Func< + NewSubscriptionGroupedWithProratedMinimumPrice, + T + > newSubscriptionGroupedWithProratedMinimum, + System::Func< + NewSubscriptionGroupedWithMeteredMinimumPrice, + T + > newSubscriptionGroupedWithMeteredMinimum, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, + T + > groupedWithMinMaxThresholds, + System::Func< + NewSubscriptionMatrixWithDisplayNamePrice, + T + > newSubscriptionMatrixWithDisplayName, + System::Func< + NewSubscriptionGroupedTieredPackagePrice, + T + > newSubscriptionGroupedTieredPackage, + System::Func< + NewSubscriptionMaxGroupTieredPackagePrice, + T + > newSubscriptionMaxGroupTieredPackage, + System::Func< + NewSubscriptionScalableMatrixWithUnitPricingPrice, + T + > newSubscriptionScalableMatrixWithUnitPricing, + System::Func< + NewSubscriptionScalableMatrixWithTieredPricingPrice, + T + > newSubscriptionScalableMatrixWithTieredPricing, + System::Func< + NewSubscriptionCumulativeGroupedBulkPrice, + T + > newSubscriptionCumulativeGroupedBulk, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, + T + > cumulativeGroupedAllocation, + System::Func newSubscriptionMinimumComposite, + System::Func percent, + System::Func< + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput, + T + > eventOutput ) { - value = this.Value as 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; + return this.Value switch + { + NewSubscriptionUnitPrice value => newSubscriptionUnit(value), + NewSubscriptionTieredPrice value => newSubscriptionTiered(value), + NewSubscriptionBulkPrice value => newSubscriptionBulk(value), + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value => + bulkWithFilters(value), + NewSubscriptionPackagePrice value => newSubscriptionPackage(value), + NewSubscriptionMatrixPrice value => newSubscriptionMatrix(value), + NewSubscriptionThresholdTotalAmountPrice value => newSubscriptionThresholdTotalAmount( + value + ), + NewSubscriptionTieredPackagePrice value => newSubscriptionTieredPackage(value), + NewSubscriptionTieredWithMinimumPrice value => newSubscriptionTieredWithMinimum(value), + NewSubscriptionGroupedTieredPrice value => newSubscriptionGroupedTiered(value), + NewSubscriptionTieredPackageWithMinimumPrice value => + newSubscriptionTieredPackageWithMinimum(value), + NewSubscriptionPackageWithAllocationPrice value => newSubscriptionPackageWithAllocation( + value + ), + NewSubscriptionUnitWithPercentPrice value => newSubscriptionUnitWithPercent(value), + NewSubscriptionMatrixWithAllocationPrice value => newSubscriptionMatrixWithAllocation( + value + ), + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value => + tieredWithProration(value), + NewSubscriptionUnitWithProrationPrice value => newSubscriptionUnitWithProration(value), + NewSubscriptionGroupedAllocationPrice value => newSubscriptionGroupedAllocation(value), + NewSubscriptionBulkWithProrationPrice value => newSubscriptionBulkWithProration(value), + NewSubscriptionGroupedWithProratedMinimumPrice value => + newSubscriptionGroupedWithProratedMinimum(value), + NewSubscriptionGroupedWithMeteredMinimumPrice value => + newSubscriptionGroupedWithMeteredMinimum(value), + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value => + groupedWithMinMaxThresholds(value), + NewSubscriptionMatrixWithDisplayNamePrice value => newSubscriptionMatrixWithDisplayName( + value + ), + NewSubscriptionGroupedTieredPackagePrice value => newSubscriptionGroupedTieredPackage( + value + ), + NewSubscriptionMaxGroupTieredPackagePrice value => newSubscriptionMaxGroupTieredPackage( + value + ), + NewSubscriptionScalableMatrixWithUnitPricingPrice value => + newSubscriptionScalableMatrixWithUnitPricing(value), + NewSubscriptionScalableMatrixWithTieredPricingPrice value => + newSubscriptionScalableMatrixWithTieredPricing(value), + NewSubscriptionCumulativeGroupedBulkPrice value => newSubscriptionCumulativeGroupedBulk( + value + ), + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value => + cumulativeGroupedAllocation(value), + NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), + SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value => percent(value), + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value => eventOutput( + value + ), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" + ), + }; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedWithMeteredMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewSubscriptionGroupedWithMeteredMinimumPrice? value - ) - { - value = this.Value as NewSubscriptionGroupedWithMeteredMinimumPrice; - return value != null; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds? value - ) - { - value = - this.Value - as SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds; - return value != null; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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.TryPickNewSubscriptionMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMatrixWithDisplayName( - [NotNullWhen(true)] out NewSubscriptionMatrixWithDisplayNamePrice? value - ) - { - value = this.Value as NewSubscriptionMatrixWithDisplayNamePrice; - return value != null; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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.TryPickNewSubscriptionGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedTieredPackage( - [NotNullWhen(true)] out NewSubscriptionGroupedTieredPackagePrice? value - ) - { - value = this.Value as NewSubscriptionGroupedTieredPackagePrice; - return value != null; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value + ) => new(value); - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionMaxGroupTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMaxGroupTieredPackage( - [NotNullWhen(true)] out NewSubscriptionMaxGroupTieredPackagePrice? value - ) - { - value = this.Value as NewSubscriptionMaxGroupTieredPackagePrice; - return value != null; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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.TryPickNewSubscriptionScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewSubscriptionScalableMatrixWithUnitPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithUnitPricingPrice? value - ) - { - value = this.Value as NewSubscriptionScalableMatrixWithUnitPricingPrice; - return value != null; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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.TryPickNewSubscriptionScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewSubscriptionScalableMatrixWithTieredPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithTieredPricingPrice? value - ) - { - value = this.Value as NewSubscriptionScalableMatrixWithTieredPricingPrice; - return value != null; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionThresholdTotalAmountPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPackagePrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredWithMinimumPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedTieredPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPackageWithMinimumPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionPackageWithAllocationPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitWithPercentPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixWithAllocationPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitWithProrationPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedAllocationPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionBulkWithProrationPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedWithProratedMinimumPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedWithMeteredMinimumPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixWithDisplayNamePrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedTieredPackagePrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMaxGroupTieredPackagePrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionScalableMatrixWithUnitPricingPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionScalableMatrixWithTieredPricingPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionCumulativeGroupedBulkPrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMinimumCompositePrice value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value + ) => new(value); + + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value + ) => new(value); /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). /// - /// Consider using or if you need to handle every variant. + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). /// - /// - /// - /// if (instance.TryPickNewSubscriptionCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewSubscriptionCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// + /// Thrown when the instance does not pass validation. + /// /// - public bool TryPickNewSubscriptionCumulativeGroupedBulk( - [NotNullWhen(true)] out NewSubscriptionCumulativeGroupedBulkPrice? value - ) + public override void Validate() { - value = this.Value as NewSubscriptionCumulativeGroupedBulkPrice; - return value != null; + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" + ); + } + this.Switch( + (newSubscriptionUnit) => newSubscriptionUnit.Validate(), + (newSubscriptionTiered) => newSubscriptionTiered.Validate(), + (newSubscriptionBulk) => newSubscriptionBulk.Validate(), + (bulkWithFilters) => bulkWithFilters.Validate(), + (newSubscriptionPackage) => newSubscriptionPackage.Validate(), + (newSubscriptionMatrix) => newSubscriptionMatrix.Validate(), + (newSubscriptionThresholdTotalAmount) => newSubscriptionThresholdTotalAmount.Validate(), + (newSubscriptionTieredPackage) => newSubscriptionTieredPackage.Validate(), + (newSubscriptionTieredWithMinimum) => newSubscriptionTieredWithMinimum.Validate(), + (newSubscriptionGroupedTiered) => newSubscriptionGroupedTiered.Validate(), + (newSubscriptionTieredPackageWithMinimum) => + newSubscriptionTieredPackageWithMinimum.Validate(), + (newSubscriptionPackageWithAllocation) => + newSubscriptionPackageWithAllocation.Validate(), + (newSubscriptionUnitWithPercent) => newSubscriptionUnitWithPercent.Validate(), + (newSubscriptionMatrixWithAllocation) => newSubscriptionMatrixWithAllocation.Validate(), + (tieredWithProration) => tieredWithProration.Validate(), + (newSubscriptionUnitWithProration) => newSubscriptionUnitWithProration.Validate(), + (newSubscriptionGroupedAllocation) => newSubscriptionGroupedAllocation.Validate(), + (newSubscriptionBulkWithProration) => newSubscriptionBulkWithProration.Validate(), + (newSubscriptionGroupedWithProratedMinimum) => + newSubscriptionGroupedWithProratedMinimum.Validate(), + (newSubscriptionGroupedWithMeteredMinimum) => + newSubscriptionGroupedWithMeteredMinimum.Validate(), + (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), + (newSubscriptionMatrixWithDisplayName) => + newSubscriptionMatrixWithDisplayName.Validate(), + (newSubscriptionGroupedTieredPackage) => newSubscriptionGroupedTieredPackage.Validate(), + (newSubscriptionMaxGroupTieredPackage) => + newSubscriptionMaxGroupTieredPackage.Validate(), + (newSubscriptionScalableMatrixWithUnitPricing) => + newSubscriptionScalableMatrixWithUnitPricing.Validate(), + (newSubscriptionScalableMatrixWithTieredPricing) => + newSubscriptionScalableMatrixWithTieredPricing.Validate(), + (newSubscriptionCumulativeGroupedBulk) => + newSubscriptionCumulativeGroupedBulk.Validate(), + (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), + (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), + (percent) => percent.Validate(), + (eventOutput) => eventOutput.Validate() + ); } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation? value - ) + public virtual bool Equals(SubscriptionSchedulePlanChangeParamsReplacePricePrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() { - value = - this.Value - as SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation; - 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.TryPickMinimum(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] out SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum? value - ) + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum; - return value != null; + 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, + }; } +} - /// - /// Returns true and sets the 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 +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter + : JsonConverter +{ + public override SubscriptionSchedulePlanChangeParamsReplacePricePrice? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - value = this.Value as NewSubscriptionMinimumCompositePrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickPercent(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePricePercent` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickPercent( - [NotNullWhen(true)] out SubscriptionSchedulePlanChangeParamsReplacePricePricePercent? value - ) - { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePricePercent; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickEventOutput(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickEventOutput( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput? value - ) - { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, - /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, - /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action newSubscriptionUnit, - System::Action newSubscriptionTiered, - System::Action newSubscriptionBulk, - System::Action bulkWithFilters, - System::Action newSubscriptionPackage, - System::Action newSubscriptionMatrix, - System::Action newSubscriptionThresholdTotalAmount, - System::Action newSubscriptionTieredPackage, - System::Action newSubscriptionTieredWithMinimum, - System::Action newSubscriptionGroupedTiered, - System::Action newSubscriptionTieredPackageWithMinimum, - System::Action newSubscriptionPackageWithAllocation, - System::Action newSubscriptionUnitWithPercent, - System::Action newSubscriptionMatrixWithAllocation, - System::Action tieredWithProration, - System::Action newSubscriptionUnitWithProration, - System::Action newSubscriptionGroupedAllocation, - System::Action newSubscriptionBulkWithProration, - System::Action newSubscriptionGroupedWithProratedMinimum, - System::Action newSubscriptionGroupedWithMeteredMinimum, - System::Action groupedWithMinMaxThresholds, - System::Action newSubscriptionMatrixWithDisplayName, - System::Action newSubscriptionGroupedTieredPackage, - System::Action newSubscriptionMaxGroupTieredPackage, - System::Action newSubscriptionScalableMatrixWithUnitPricing, - System::Action newSubscriptionScalableMatrixWithTieredPricing, - System::Action newSubscriptionCumulativeGroupedBulk, - System::Action cumulativeGroupedAllocation, - System::Action minimum, - System::Action newSubscriptionMinimumComposite, - System::Action percent, - System::Action eventOutput - ) - { - switch (this.Value) - { - case NewSubscriptionUnitPrice value: - newSubscriptionUnit(value); - break; - case NewSubscriptionTieredPrice value: - newSubscriptionTiered(value); - break; - case NewSubscriptionBulkPrice value: - newSubscriptionBulk(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value: - bulkWithFilters(value); - break; - case NewSubscriptionPackagePrice value: - newSubscriptionPackage(value); - break; - case NewSubscriptionMatrixPrice value: - newSubscriptionMatrix(value); - break; - case NewSubscriptionThresholdTotalAmountPrice value: - newSubscriptionThresholdTotalAmount(value); - break; - case NewSubscriptionTieredPackagePrice value: - newSubscriptionTieredPackage(value); - break; - case NewSubscriptionTieredWithMinimumPrice value: - newSubscriptionTieredWithMinimum(value); - break; - case NewSubscriptionGroupedTieredPrice value: - newSubscriptionGroupedTiered(value); - break; - case NewSubscriptionTieredPackageWithMinimumPrice value: - newSubscriptionTieredPackageWithMinimum(value); - break; - case NewSubscriptionPackageWithAllocationPrice value: - newSubscriptionPackageWithAllocation(value); - break; - case NewSubscriptionUnitWithPercentPrice value: - newSubscriptionUnitWithPercent(value); - break; - case NewSubscriptionMatrixWithAllocationPrice value: - newSubscriptionMatrixWithAllocation(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value: - tieredWithProration(value); - break; - case NewSubscriptionUnitWithProrationPrice value: - newSubscriptionUnitWithProration(value); - break; - case NewSubscriptionGroupedAllocationPrice value: - newSubscriptionGroupedAllocation(value); - break; - case NewSubscriptionBulkWithProrationPrice value: - newSubscriptionBulkWithProration(value); - break; - case NewSubscriptionGroupedWithProratedMinimumPrice value: - newSubscriptionGroupedWithProratedMinimum(value); - break; - case NewSubscriptionGroupedWithMeteredMinimumPrice value: - newSubscriptionGroupedWithMeteredMinimum(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value: - groupedWithMinMaxThresholds(value); - break; - case NewSubscriptionMatrixWithDisplayNamePrice value: - newSubscriptionMatrixWithDisplayName(value); - break; - case NewSubscriptionGroupedTieredPackagePrice value: - newSubscriptionGroupedTieredPackage(value); - break; - case NewSubscriptionMaxGroupTieredPackagePrice value: - newSubscriptionMaxGroupTieredPackage(value); - break; - case NewSubscriptionScalableMatrixWithUnitPricingPrice value: - newSubscriptionScalableMatrixWithUnitPricing(value); - break; - case NewSubscriptionScalableMatrixWithTieredPricingPrice value: - newSubscriptionScalableMatrixWithTieredPricing(value); - break; - case NewSubscriptionCumulativeGroupedBulkPrice value: - newSubscriptionCumulativeGroupedBulk(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value: - cumulativeGroupedAllocation(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value: - minimum(value); - break; - case NewSubscriptionMinimumCompositePrice value: - newSubscriptionMinimumComposite(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value: - percent(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value: - eventOutput(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" - ); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, - /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, - /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func newSubscriptionUnit, - System::Func newSubscriptionTiered, - System::Func newSubscriptionBulk, - System::Func< - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters, - T - > bulkWithFilters, - System::Func newSubscriptionPackage, - System::Func newSubscriptionMatrix, - System::Func< - NewSubscriptionThresholdTotalAmountPrice, - T - > newSubscriptionThresholdTotalAmount, - System::Func newSubscriptionTieredPackage, - System::Func newSubscriptionTieredWithMinimum, - System::Func newSubscriptionGroupedTiered, - System::Func< - NewSubscriptionTieredPackageWithMinimumPrice, - T - > newSubscriptionTieredPackageWithMinimum, - System::Func< - NewSubscriptionPackageWithAllocationPrice, - T - > newSubscriptionPackageWithAllocation, - System::Func newSubscriptionUnitWithPercent, - System::Func< - NewSubscriptionMatrixWithAllocationPrice, - T - > newSubscriptionMatrixWithAllocation, - System::Func< - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration, - T - > tieredWithProration, - System::Func newSubscriptionUnitWithProration, - System::Func newSubscriptionGroupedAllocation, - System::Func newSubscriptionBulkWithProration, - System::Func< - NewSubscriptionGroupedWithProratedMinimumPrice, - T - > newSubscriptionGroupedWithProratedMinimum, - System::Func< - NewSubscriptionGroupedWithMeteredMinimumPrice, - T - > newSubscriptionGroupedWithMeteredMinimum, - System::Func< - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, - T - > groupedWithMinMaxThresholds, - System::Func< - NewSubscriptionMatrixWithDisplayNamePrice, - T - > newSubscriptionMatrixWithDisplayName, - System::Func< - NewSubscriptionGroupedTieredPackagePrice, - T - > newSubscriptionGroupedTieredPackage, - System::Func< - NewSubscriptionMaxGroupTieredPackagePrice, - T - > newSubscriptionMaxGroupTieredPackage, - System::Func< - NewSubscriptionScalableMatrixWithUnitPricingPrice, - T - > newSubscriptionScalableMatrixWithUnitPricing, - System::Func< - NewSubscriptionScalableMatrixWithTieredPricingPrice, - T - > newSubscriptionScalableMatrixWithTieredPricing, - System::Func< - NewSubscriptionCumulativeGroupedBulkPrice, - T - > newSubscriptionCumulativeGroupedBulk, - System::Func< - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, - System::Func newSubscriptionMinimumComposite, - System::Func percent, - System::Func< - SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput, - T - > eventOutput - ) - { - return this.Value switch - { - NewSubscriptionUnitPrice value => newSubscriptionUnit(value), - NewSubscriptionTieredPrice value => newSubscriptionTiered(value), - NewSubscriptionBulkPrice value => newSubscriptionBulk(value), - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value => - bulkWithFilters(value), - NewSubscriptionPackagePrice value => newSubscriptionPackage(value), - NewSubscriptionMatrixPrice value => newSubscriptionMatrix(value), - NewSubscriptionThresholdTotalAmountPrice value => newSubscriptionThresholdTotalAmount( - value - ), - NewSubscriptionTieredPackagePrice value => newSubscriptionTieredPackage(value), - NewSubscriptionTieredWithMinimumPrice value => newSubscriptionTieredWithMinimum(value), - NewSubscriptionGroupedTieredPrice value => newSubscriptionGroupedTiered(value), - NewSubscriptionTieredPackageWithMinimumPrice value => - newSubscriptionTieredPackageWithMinimum(value), - NewSubscriptionPackageWithAllocationPrice value => newSubscriptionPackageWithAllocation( - value - ), - NewSubscriptionUnitWithPercentPrice value => newSubscriptionUnitWithPercent(value), - NewSubscriptionMatrixWithAllocationPrice value => newSubscriptionMatrixWithAllocation( - value - ), - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value => - tieredWithProration(value), - NewSubscriptionUnitWithProrationPrice value => newSubscriptionUnitWithProration(value), - NewSubscriptionGroupedAllocationPrice value => newSubscriptionGroupedAllocation(value), - NewSubscriptionBulkWithProrationPrice value => newSubscriptionBulkWithProration(value), - NewSubscriptionGroupedWithProratedMinimumPrice value => - newSubscriptionGroupedWithProratedMinimum(value), - NewSubscriptionGroupedWithMeteredMinimumPrice value => - newSubscriptionGroupedWithMeteredMinimum(value), - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value => - groupedWithMinMaxThresholds(value), - NewSubscriptionMatrixWithDisplayNamePrice value => newSubscriptionMatrixWithDisplayName( - value - ), - NewSubscriptionGroupedTieredPackagePrice value => newSubscriptionGroupedTieredPackage( - value - ), - NewSubscriptionMaxGroupTieredPackagePrice value => newSubscriptionMaxGroupTieredPackage( - value - ), - NewSubscriptionScalableMatrixWithUnitPricingPrice value => - newSubscriptionScalableMatrixWithUnitPricing(value), - NewSubscriptionScalableMatrixWithTieredPricingPrice value => - newSubscriptionScalableMatrixWithTieredPricing(value), - NewSubscriptionCumulativeGroupedBulkPrice value => newSubscriptionCumulativeGroupedBulk( - value - ), - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value => - cumulativeGroupedAllocation(value), - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value => minimum(value), - NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), - SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value => percent(value), - SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value => eventOutput( - value - ), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" - ), - }; - } - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionBulkPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionPackagePrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionThresholdTotalAmountPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPackagePrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredWithMinimumPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitWithPercentPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixWithAllocationPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMaxGroupTieredPackagePrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionScalableMatrixWithUnitPricingPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionScalableMatrixWithTieredPricingPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMinimumCompositePrice value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value - ) => new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" - ); - } - this.Switch( - (newSubscriptionUnit) => newSubscriptionUnit.Validate(), - (newSubscriptionTiered) => newSubscriptionTiered.Validate(), - (newSubscriptionBulk) => newSubscriptionBulk.Validate(), - (bulkWithFilters) => bulkWithFilters.Validate(), - (newSubscriptionPackage) => newSubscriptionPackage.Validate(), - (newSubscriptionMatrix) => newSubscriptionMatrix.Validate(), - (newSubscriptionThresholdTotalAmount) => newSubscriptionThresholdTotalAmount.Validate(), - (newSubscriptionTieredPackage) => newSubscriptionTieredPackage.Validate(), - (newSubscriptionTieredWithMinimum) => newSubscriptionTieredWithMinimum.Validate(), - (newSubscriptionGroupedTiered) => newSubscriptionGroupedTiered.Validate(), - (newSubscriptionTieredPackageWithMinimum) => - newSubscriptionTieredPackageWithMinimum.Validate(), - (newSubscriptionPackageWithAllocation) => - newSubscriptionPackageWithAllocation.Validate(), - (newSubscriptionUnitWithPercent) => newSubscriptionUnitWithPercent.Validate(), - (newSubscriptionMatrixWithAllocation) => newSubscriptionMatrixWithAllocation.Validate(), - (tieredWithProration) => tieredWithProration.Validate(), - (newSubscriptionUnitWithProration) => newSubscriptionUnitWithProration.Validate(), - (newSubscriptionGroupedAllocation) => newSubscriptionGroupedAllocation.Validate(), - (newSubscriptionBulkWithProration) => newSubscriptionBulkWithProration.Validate(), - (newSubscriptionGroupedWithProratedMinimum) => - newSubscriptionGroupedWithProratedMinimum.Validate(), - (newSubscriptionGroupedWithMeteredMinimum) => - newSubscriptionGroupedWithMeteredMinimum.Validate(), - (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), - (newSubscriptionMatrixWithDisplayName) => - newSubscriptionMatrixWithDisplayName.Validate(), - (newSubscriptionGroupedTieredPackage) => newSubscriptionGroupedTieredPackage.Validate(), - (newSubscriptionMaxGroupTieredPackage) => - newSubscriptionMaxGroupTieredPackage.Validate(), - (newSubscriptionScalableMatrixWithUnitPricing) => - newSubscriptionScalableMatrixWithUnitPricing.Validate(), - (newSubscriptionScalableMatrixWithTieredPricing) => - newSubscriptionScalableMatrixWithTieredPricing.Validate(), - (newSubscriptionCumulativeGroupedBulk) => - newSubscriptionCumulativeGroupedBulk.Validate(), - (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), - (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), - (percent) => percent.Validate(), - (eventOutput) => eventOutput.Validate() - ); - } - - public virtual bool Equals(SubscriptionSchedulePlanChangeParamsReplacePricePrice? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter - : JsonConverter -{ - public override SubscriptionSchedulePlanChangeParamsReplacePricePrice? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try - { - modelType = element.GetProperty("model_type").GetString(); - } - catch - { - modelType = null; - } - - switch (modelType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk_with_filters": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "threshold_total_amount": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_with_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_tiered": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_package_with_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "package_with_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "unit_with_percent": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix_with_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "unit_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_prorated_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_metered_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix_with_display_name": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "max_group_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_unit_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_tiered_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_bulk": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum_composite": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "percent": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "event_output": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new SubscriptionSchedulePlanChangeParamsReplacePricePrice(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePrice? value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value?.Json, options); - } -} - -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters - : JsonModel -{ - /// - /// Configuration for bulk_with_filters pricing - /// - public required SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); - } - init { this._rawData.Set("bulk_with_filters_config", value); } - } - - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum< - string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence - > Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum< - string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence - > - >("cadence"); - } - init { this._rawData.Set("cadence", value); } - } - - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } - } - - /// - /// The pricing model type - /// - public JsonElement ModelType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } - } - - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } - - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } - } - - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } - - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); - } - init { this._rawData.Set("currency", value); } - } - - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } - - /// - /// An alias for the price. - /// - public string? ExternalPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } - } - - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } - - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } - } - - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } - - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. - /// - public IReadOnlyDictionary? Metadata - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); - } - } - - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); - } - init { this._rawData.Set("reference_id", value); } - } - - /// - public override void Validate() - { - this.BulkWithFiltersConfig.Validate(); - this.Cadence.Validate(); - _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("bulk_with_filters") - ) - ) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - _ = this.Currency; - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - _ = this.ReferenceID; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() - { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters - ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters) { } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters.FromRawUnchecked( - rawData - ); -} - -/// -/// Configuration for bulk_with_filters pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - : JsonModel -{ - /// - /// Property filters to apply (all must match) - /// - public required IReadOnlyList Filters - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("filters"); - } - init - { - this._rawData.Set< - ImmutableArray - >("filters", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - /// Bulk tiers for rating based on total usage volume - /// - public required IReadOnlyList Tiers - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); - } - } - - /// - public override void Validate() - { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() - { } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - ) - : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig - ) { } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked( - rawData - ); -} - -/// -/// Configuration for a single property filter -/// -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - : JsonModel -{ - /// - /// Event property key to filter on - /// - public required string PropertyKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_key"); - } - init { this._rawData.Set("property_key", value); } - } - - /// - /// Event property value to match - /// - public required string PropertyValue - { - get - { - 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 + 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() - { } + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - ) - : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - ) { } + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - string unitAmount - ) - : this() - { - this.UnitAmount = unitAmount; - } -} + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked( - rawData - ); -} + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -/// -/// The cadence to bill for this price on. -/// -[JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceConverter) -)] -public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceConverter - : JsonConverter -{ - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, - "semi_annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.SemiAnnual, - "monthly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Monthly, - "quarterly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Quarterly, - "one_time" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.OneTime, - "custom" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence)(-1), - }; - } + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public override void Write( - Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch + return new(element); + } + case "tiered_package_with_minimum": { - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual => - "annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.SemiAnnual => - "semi_annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Monthly => - "monthly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Quarterly => - "quarterly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.OneTime => - "one_time", - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Custom => - "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } -[JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigConverter) -)] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig - : ModelBase -{ - public object? Value { get; } = null; + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - JsonElement? _element = null; + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } + + 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - } + return new(element); + } + case "grouped_with_min_max_thresholds": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) - { - return this.Value switch - { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" - ), - }; - } + return new(element); + } + case "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - 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( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigConverter - : JsonConverter -{ - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } + return new(element); + } + case "minimum_composite": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + deserialized.Validate(); + return new(deserialized, element); + } + } + catch (System::Exception e) + when (e is JsonException || e is OrbInvalidDataException) + { + // ignore + } - switch (conversionRateType) - { - case "unit": + return new(element); + } + case "percent": { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -15559,14 +14070,15 @@ JsonSerializerOptions options return new(element); } - case "tiered": + case "event_output": { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { deserialized.Validate(); @@ -15583,38 +14095,51 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - element - ); + return new SubscriptionSchedulePlanChangeParamsReplacePricePrice(element); } } } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePrice? value, JsonSerializerOptions options ) { - JsonSerializer.Serialize(writer, value.Json, options); + JsonSerializer.Serialize(writer, value?.Json, options); } } [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters, + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters : JsonModel { + /// + /// Configuration for bulk_with_filters pricing + /// + public required SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_filters_config" + ); + } + init { this._rawData.Set("bulk_with_filters_config", value); } + } + /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence > Cadence { get @@ -15623,7 +14148,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence > >("cadence"); } @@ -15669,21 +14194,6 @@ public required string Name init { this._rawData.Set("name", value); } } - /// - /// Configuration for tiered_with_proration pricing - /// - public required SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "tiered_with_proration_config" - ); - } - init { this._rawData.Set("tiered_with_proration_config", value); } - } - /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -15743,12 +14253,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" ); } @@ -15839,6 +14349,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 @@ -15877,19 +14400,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(); @@ -15901,32 +14424,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration) { } + : base(subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( FrozenDictionary rawData ) { @@ -15934,8 +14461,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15943,147 +14470,193 @@ 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 { - return JsonSerializer.Deserialize(ref reader, options) switch + get { - "annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, - "semi_annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual, - "monthly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly, - "quarterly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly, - "one_time" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime, - "custom" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence)( - -1 - ), - }; + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); + } } - public override void Write( - Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence value, - JsonSerializerOptions options + /// + public override void Validate() + { + foreach (var item in this.Filters) + { + item.Validate(); + } + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + ) + : base( + subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + ) { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + 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 - ); + 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 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( IReadOnlyDictionary rawData ) { @@ -16092,7 +14665,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( FrozenDictionary rawData ) { @@ -16100,92 +14673,86 @@ 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier ) : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( IReadOnlyDictionary rawData ) { @@ -16194,7 +14761,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( FrozenDictionary rawData ) { @@ -16202,31 +14769,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(SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceConverter) )] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig +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; @@ -16244,7 +14894,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16253,7 +14903,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationC this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16262,7 +14912,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationC this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( JsonElement element ) { @@ -16346,7 +14996,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" ); } } @@ -16382,16 +15032,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -16410,18 +15060,18 @@ 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 - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -16429,13 +15079,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16500,7 +15163,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( element ); } @@ -16509,7 +15172,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -16519,11 +15182,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration : JsonModel { /// @@ -16531,7 +15194,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePrice /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > Cadence { get @@ -16540,26 +15203,11 @@ 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); } + init { this._rawData.Set("cadence", value); } } /// @@ -16601,6 +15249,21 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for tiered_with_proration pricing + /// + public required SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig TieredWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_proration_config" + ); + } + init { this._rawData.Set("tiered_with_proration_config", value); } + } + /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -16660,12 +15323,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" ); } @@ -16756,6 +15419,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 @@ -16795,18 +15471,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(); @@ -16818,32 +15494,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds) { } + : base(subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration( FrozenDictionary rawData ) { @@ -16851,8 +15531,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16860,14 +15540,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration.FromRawUnchecked( rawData ); } @@ -16876,9 +15556,9 @@ IReadOnlyDictionary rawData /// The cadence to bill for this price on. /// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceConverter) )] -public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence +public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence { Annual, SemiAnnual, @@ -16888,10 +15568,10 @@ public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinM Custom, } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -16900,27 +15580,26 @@ 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, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -16928,17 +15607,17 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime => + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom => + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -16950,89 +15629,166 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for tiered_with_proration pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration /// - public required string GroupingKey + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); } - init { this._rawData.Set("grouping_key", value); } } - /// - /// The maximum amount to charge each group - /// - public required string MaximumCharge + /// + public override void Validate() { - get + foreach (var item in this.Tiers) { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + item.Validate(); } - init { this._rawData.Set("maximum_charge", value); } } + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + ) + : base( + subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig + ) { } +#pragma warning restore CS8618 + + 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() + { + this.Tiers = tiers; + } +} + +class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Configuration for a single tiered with proration tier +/// +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier + : JsonModel +{ /// - /// The minimum amount to charge each group, regardless of usage + /// Inclusive tier starting value /// - public required string MinimumCharge + public required string TierLowerBound { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNotNullClass("tier_lower_bound"); } - init { this._rawData.Set("minimum_charge", value); } + init { this._rawData.Set("tier_lower_bound", value); } } /// - /// The base price charged per group + /// Amount per unit /// - public required string PerUnitRate + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("per_unit_rate", value); } + init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.TierLowerBound; + _ = this.UnitAmount; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier() { } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier ) : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + subscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData ) { @@ -17041,7 +15797,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -17049,8 +15805,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17058,22 +15814,22 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTierFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -17091,7 +15847,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17100,7 +15856,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThr this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17109,7 +15865,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThr this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( JsonElement element ) { @@ -17193,7 +15949,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig" ); } } @@ -17229,16 +15985,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -17257,18 +16013,18 @@ 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 - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -17276,13 +16032,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17347,7 +16116,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( element ); } @@ -17356,7 +16125,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -17366,11 +16135,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds : JsonModel { /// @@ -17378,7 +16147,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePrice /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > Cadence { get @@ -17387,7 +16156,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >("cadence"); } @@ -17395,18 +16164,18 @@ public required ApiEnum< } /// - /// Configuration for cumulative_grouped_allocation pricing + /// Configuration for grouped_with_min_max_thresholds pricing /// - public required SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" + return this._rawData.GetNotNullClass( + "grouped_with_min_max_thresholds_config" ); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } } /// @@ -17507,12 +16276,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" ); } @@ -17603,6 +16372,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 @@ -17642,12 +16424,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") ) ) { @@ -17665,32 +16447,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation) { } + : base(subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds( FrozenDictionary rawData ) { @@ -17698,8 +16484,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17707,14 +16493,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( rawData ); } @@ -17723,9 +16509,9 @@ IReadOnlyDictionary rawData /// The cadence to bill for this price on. /// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter) )] -public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence +public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence { Annual, SemiAnnual, @@ -17735,10 +16521,10 @@ public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroup Custom, } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -17747,19 +16533,19 @@ JsonSerializerOptions options return JsonSerializer.Deserialize(ref reader, options) switch { "annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual, "monthly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly, "one_time" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime, "custom" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom, _ => - (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence)( + (SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence)( -1 ), }; @@ -17767,7 +16553,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -17775,17 +16561,17 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom => + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -17797,89 +16583,92 @@ 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + subscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData ) { @@ -17888,7 +16677,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -17896,8 +16685,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17905,22 +16694,22 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -17938,7 +16727,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17947,7 +16736,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAll this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17956,7 +16745,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAll this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( JsonElement element ) { @@ -18040,7 +16829,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ); } } @@ -18076,16 +16865,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -18104,18 +16893,18 @@ 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 - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -18123,13 +16912,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -18194,7 +16996,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -18203,7 +17005,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -18213,56 +17015,60 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation + : JsonModel { /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum< + string, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + > >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// The id of the item the price will be associated with. + /// Configuration for cumulative_grouped_allocation pricing /// - public required string ItemID + public required SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } } /// - /// Configuration for minimum pricing + /// The id of the item the price will be associated with. /// - public required SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig MinimumConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("minimum_config", value); } + init { this._rawData.Set("item_id", value); } } /// @@ -18350,12 +17156,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" ); } @@ -18446,6 +17252,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 @@ -18485,9 +17304,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"); } @@ -18503,32 +17327,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum() + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum( - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum subscriptionSchedulePlanChangeParamsReplacePricePriceMinimum +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceMinimum) { } + : base(subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation( FrozenDictionary rawData ) { @@ -18536,8 +17364,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -18545,22 +17373,25 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum.FromRawUnchecked(rawData); + ) => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked( + rawData + ); } /// /// The cadence to bill for this price on. /// [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadenceConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceConverter) )] -public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence +public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence { Annual, SemiAnnual, @@ -18570,10 +17401,10 @@ public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence Custom, } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -18581,23 +17412,28 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, + "annual" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.SemiAnnual, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual, "monthly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Monthly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Quarterly, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly, "one_time" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.OneTime, - "custom" => SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence)(-1), + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime, + "custom" => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom, + _ => + (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -18605,17 +17441,17 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Monthly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.OneTime => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Custom => + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -18627,66 +17463,92 @@ 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) - : base(subscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig) { } + : base( + subscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData ) { @@ -18695,7 +17557,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( FrozenDictionary rawData ) { @@ -18703,40 +17565,31 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig( - string minimumAmount - ) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -18754,7 +17607,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -18763,7 +17616,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRat this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -18772,7 +17625,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRat this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( JsonElement element ) { @@ -18856,7 +17709,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ); } } @@ -18892,16 +17745,16 @@ public T Match( SharedUnitConversionRateConfig value => unit(value), SharedTieredConversionRateConfig value => tiered(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -18920,18 +17773,18 @@ 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 - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -18939,13 +17792,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfigConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -19010,7 +17876,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -19019,7 +17885,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -19262,6 +18128,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 @@ -19319,6 +18198,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -19328,10 +18208,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 @@ -19475,10 +18358,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 @@ -19720,10 +18606,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() { @@ -19731,7 +18617,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsReplacePricePricePercentConversionRateConfigConverter @@ -20058,6 +18957,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 @@ -20120,6 +19032,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -20129,10 +19042,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 @@ -20309,11 +19225,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 @@ -20557,10 +19476,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() { @@ -20568,7 +19487,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputConversionRateConfigConverter 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/SubscriptionTriggerPhaseParams.cs b/src/Orb/Models/Subscriptions/SubscriptionTriggerPhaseParams.cs index 5477bafa1..a0b01c36e 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +167,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..770e18ba0 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.cs index 3e356fe6b..73088ae9e 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Subscriptions/SubscriptionUnschedulePendingPlanChangesParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParams.cs index 7f50496aa..413cc10e3 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,34 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +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/Subscriptions/SubscriptionUpdateFixedFeeQuantityParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUpdateFixedFeeQuantityParams.cs index afd9dab9f..abb2d52a5 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +229,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..6888dad85 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +220,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..351f9636f 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,36 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + 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 + ); + + 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 +193,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -338,10 +380,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() { @@ -349,7 +391,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class TrialEndDateConverter : JsonConverter @@ -380,7 +435,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/SubscriptionUsage.cs b/src/Orb/Models/Subscriptions/SubscriptionUsage.cs index 4380c2c61..d33e5c671 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() { @@ -200,7 +200,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + UngroupedSubscriptionUsage _ => 0, + GroupedSubscriptionUsage _ => 1, + _ => -1, + }; + } } sealed class SubscriptionUsageConverter : JsonConverter @@ -288,8 +301,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 +396,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 +461,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 +537,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 +659,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 +773,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 +846,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 +919,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 +1000,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/TopLevelPingParams.cs b/src/Orb/Models/TopLevel/TopLevelPingParams.cs index 97a7b68b7..4b6e37c44 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,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(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 +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/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) { 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 diff --git a/src/Orb/OrbClient.cs b/src/Orb/OrbClient.cs index f3af3071e..874a57e98 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, @@ -500,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. @@ -609,6 +639,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/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 cbf3ddb5b..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 { @@ -17,16 +22,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 +51,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 +61,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) 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/Customers/Credits/ILedgerService.cs b/src/Orb/Services/Customers/Credits/ILedgerService.cs index 11adc9dec..3f80b8361 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 { @@ -49,10 +52,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 @@ -149,7 +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. + /// 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 @@ -247,7 +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. + /// 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 @@ -328,10 +341,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 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 71044e6ab..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 { @@ -39,6 +42,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 +68,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, 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 c2d358645..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 { @@ -62,6 +65,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 +139,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/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..c481d392e 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 { @@ -52,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, 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 36d477592..72a0cf00d 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 { @@ -37,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, @@ -138,6 +145,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 +346,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/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/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..7113aff52 --- /dev/null +++ b/src/Orb/Services/ILicenseTypeService.cs @@ -0,0 +1,123 @@ +using System; +using System.Threading; +using System.Threading.Tasks; +using Orb.Core; +using Orb.Models.LicenseTypes; + +namespace Orb.Services; + +/// +/// 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 +{ + /// + /// 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/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/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); + } +} 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 {