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..9de1b3bed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,12 +1,14 @@ name: CI on: push: - branches-ignore: - - 'generated' - - 'codegen/**' - - 'integrated/**' - - 'stl-preview-head/**' - - 'stl-preview-base/**' + branches: + - '**' + - '!integrated/**' + - '!stl-preview-head/**' + - '!stl-preview-base/**' + - '!generated' + - '!codegen/**' + - 'codegen/stl/**' pull_request: branches-ignore: - 'stl-preview-head/**' @@ -17,10 +19,10 @@ jobs: timeout-minutes: 10 name: lint runs-on: ${{ github.repository == 'stainless-sdks/orb-csharp' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up .NET uses: actions/setup-dotnet@v3 @@ -36,10 +38,10 @@ jobs: timeout-minutes: 10 name: build runs-on: ${{ github.repository == 'stainless-sdks/orb-csharp' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} - if: github.event_name == 'push' || github.event.pull_request.head.repo.fork + if: (github.event_name == 'push' || github.event.pull_request.head.repo.fork) && (github.event_name != 'push' || github.event.head_commit.message != 'codegen metadata') steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - name: Set up .NET uses: actions/setup-dotnet@v3 @@ -55,7 +57,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..1ce7f8483 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,9 @@ .prism.log +.stdy.log 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..e1694adf6 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-1ca41c4b1d872cf2a198c8cf5edeeeddac012259a7cf211b102bf137c05b8240.yml +openapi_spec_hash: 955066d4865fc42440cd81e40f5f79cd +config_hash: c01c1191b1cd696c7ca855ff6d28a8df diff --git a/CHANGELOG.md b/CHANGELOG.md index 15283c170..a1d1f15a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,88 @@ # Changelog +## 0.2.0 (2026-04-03) + +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 ([03e400a](https://github.com/orbcorp/orb-csharp/commit/03e400abe6865aa773e7252635fc6701dee560ee)) +* **api:** api update ([73bd0a2](https://github.com/orbcorp/orb-csharp/commit/73bd0a2146bf5c6aa2bf0df77a692ba97d1a2639)) +* **api:** api update ([6290055](https://github.com/orbcorp/orb-csharp/commit/6290055364753e84ecfc3f64df0b2ffd8a6cc92b)) +* **api:** api update ([7db3aea](https://github.com/orbcorp/orb-csharp/commit/7db3aeaaf44de0279863a5fb2f8d5db4b4568a78)) +* **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)) +* **client:** enable gzip decompression ([d88242b](https://github.com/orbcorp/orb-csharp/commit/d88242b8c3fc4586e85ec4be7839c160201c28cf)) + + +### Bug Fixes + +* **client:** allow cancelling when enumerating over an http response ([72b74d6](https://github.com/orbcorp/orb-csharp/commit/72b74d666cb990ed94d4d0a4266eb6faf2de3b2f)) +* **client:** don't overzealously validate union variants when deserializing ([bfe7b02](https://github.com/orbcorp/orb-csharp/commit/bfe7b02cbdba27e809c9847acc4962d66832e0f6)) +* **client:** handle path params correctly in `FromRawUnchecked` ([2901381](https://github.com/orbcorp/orb-csharp/commit/2901381e46b99135ae080c285773ce47be34a26e)) +* **client:** handle root bodies in requests properly ([7f07dde](https://github.com/orbcorp/orb-csharp/commit/7f07dde4ffbe96d2d4b06e07abeb8240c5d84656)) +* **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)) +* **docs:** make xml syntactically correct ([2764b34](https://github.com/orbcorp/orb-csharp/commit/2764b3482e43edb81853777cf0b5b8bef919c9f3)) + + +### Chores + +* change visibility of QueryString() and AddDefaultHeaders ([3f5afb6](https://github.com/orbcorp/orb-csharp/commit/3f5afb6e4e6d0c32a52e82c68c219391a09a0313)) +* **ci:** skip lint on metadata-only changes ([d17d16f](https://github.com/orbcorp/orb-csharp/commit/d17d16f09dd4259642b0f38110953c9b57d31c9f)) +* **client:** update formatting ([21e8052](https://github.com/orbcorp/orb-csharp/commit/21e805216eb0f83fc780c8a1413b376d5edf6edd)) +* **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:** tweak CI branches ([535c3d2](https://github.com/orbcorp/orb-csharp/commit/535c3d24ef7f564fd01f6d2d9c0ce2f9492b1b99)) +* **internal:** update `actions/checkout` version ([5849a89](https://github.com/orbcorp/orb-csharp/commit/5849a89be72919068177e2830142c600a0bb7aeb)) +* **internal:** update gitignore ([23ee651](https://github.com/orbcorp/orb-csharp/commit/23ee651a3460654b98b621c4b95d8e5ebfc28011)) +* **internal:** update multipart form array serialization ([4bf1d55](https://github.com/orbcorp/orb-csharp/commit/4bf1d55444620fe59fcd00c4bc99f374bcb44c6b)) +* **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)) +* **tests:** bump steady to v0.19.4 ([bfb615b](https://github.com/orbcorp/orb-csharp/commit/bfb615bb14d78728d392c184f097c987cd74b475)) +* **tests:** bump steady to v0.19.5 ([ce30819](https://github.com/orbcorp/orb-csharp/commit/ce308199fdab1617a4c666398c3280c57ac5ec5c)) +* **tests:** bump steady to v0.19.6 ([832809c](https://github.com/orbcorp/orb-csharp/commit/832809ce100870bcf6141ad72446e8ae623e501e)) +* **tests:** bump steady to v0.19.7 ([233ce7b](https://github.com/orbcorp/orb-csharp/commit/233ce7b103f45a5177c7a7bd35e9fbaafc1634cb)) +* **tests:** bump steady to v0.20.1 ([887b042](https://github.com/orbcorp/orb-csharp/commit/887b0427175840bcf6c506cb8a698534bf0d7e0c)) +* **tests:** bump steady to v0.20.2 ([387434f](https://github.com/orbcorp/orb-csharp/commit/387434f3cd5bc09b7d843aecbca0af7b54fad15a)) +* **tests:** update mock server to steady ([65880ef](https://github.com/orbcorp/orb-csharp/commit/65880ef235e4df72dfe220e0e6356a1dbccbe01a)) +* 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..886f2ffc1 100755 --- a/scripts/mock +++ b/scripts/mock @@ -19,23 +19,34 @@ fi echo "==> Starting mock server with URL ${URL}" -# Run prism mock on the given spec +# Run steady mock on the given spec if [ "$1" == "--daemon" ]; then - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & + # Pre-install the package so the download doesn't eat into the startup timeout + npm exec --package=@stdy/cli@0.20.2 -- steady --version - # Wait for server to come online + npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" &> .stdy.log & + + # Wait for server to come online via health endpoint (max 30s) echo -n "Waiting for server" - while ! grep -q "✖ fatal\|Prism is listening" ".prism.log" ; do + attempts=0 + while ! curl --silent --fail "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1; do + if ! kill -0 $! 2>/dev/null; then + echo + cat .stdy.log + exit 1 + fi + attempts=$((attempts + 1)) + if [ "$attempts" -ge 300 ]; then + echo + echo "Timed out waiting for Steady server to start" + cat .stdy.log + exit 1 + fi echo -n "." sleep 0.1 done - if grep -q "✖ fatal" ".prism.log"; then - cat .prism.log - exit 1 - fi - echo else - npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" + npm exec --package=@stdy/cli@0.20.2 -- steady --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets "$URL" fi diff --git a/scripts/test b/scripts/test index f47e4b7f6..de3111c12 100755 --- a/scripts/test +++ b/scripts/test @@ -9,8 +9,8 @@ GREEN='\033[0;32m' YELLOW='\033[0;33m' NC='\033[0m' # No Color -function prism_is_running() { - curl --silent "http://localhost:4010" >/dev/null 2>&1 +function steady_is_running() { + curl --silent "http://127.0.0.1:4010/_x-steady/health" >/dev/null 2>&1 } kill_server_on_port() { @@ -29,7 +29,7 @@ function is_overriding_api_base_url() { [ -n "$TEST_API_BASE_URL" ] } -if ! is_overriding_api_base_url && ! prism_is_running ; then +if ! is_overriding_api_base_url && ! steady_is_running ; then # When we exit this script, make sure to kill the background mock server process trap 'kill_server_on_port 4010' EXIT @@ -40,19 +40,19 @@ fi if is_overriding_api_base_url ; then echo -e "${GREEN}✔ Running tests against ${TEST_API_BASE_URL}${NC}" echo -elif ! prism_is_running ; then - echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Prism server" +elif ! steady_is_running ; then + echo -e "${RED}ERROR:${NC} The test suite will not run without a mock Steady server" echo -e "running against your OpenAPI spec." echo echo -e "To run the server, pass in the path or url of your OpenAPI" - echo -e "spec to the prism command:" + echo -e "spec to the steady command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stdy/cli@0.20.2 -- steady path/to/your.openapi.yml --host 127.0.0.1 -p 4010 --validator-query-array-format=brackets --validator-form-array-format=brackets --validator-query-object-format=brackets --validator-form-object-format=brackets${NC}" echo exit 1 else - echo -e "${GREEN}✔ Mock prism server is running with your OpenAPI spec${NC}" + echo -e "${GREEN}✔ Mock steady server is running with your OpenAPI spec${NC}" echo fi diff --git a/src/Directory.Build.props b/src/Directory.Build.props index ee85a7d11..ebd8a5702 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -12,7 +12,7 @@ true - $(NoWarn),1570,1573,1574,1591 + $(NoWarn),1573,1591 true 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..badeeb059 100644 --- a/src/Orb.Tests/Models/Customers/CustomerCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerCreateParamsTest.cs @@ -57,6 +57,7 @@ public void FieldRoundtrip_Works() new() { ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -131,6 +132,7 @@ public void FieldRoundtrip_Works() new() { ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -315,6 +317,91 @@ 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, + DefaultSharedPaymentToken = "default_shared_payment_token", + 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 @@ -329,6 +416,7 @@ public void FieldRoundtrip_Works() new() { ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -336,7 +424,12 @@ public void FieldRoundtrip_Works() List expectedPaymentProviders = [ - new() { ProviderType = ProviderType.Stripe, ExcludedPaymentMethodTypes = ["string"] }, + new() + { + ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }, ]; Assert.NotNull(model.PaymentProviders); @@ -357,6 +450,7 @@ public void SerializationRoundtrip_Works() new() { ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -381,6 +475,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -395,7 +490,12 @@ public void FieldRoundtripThroughSerialization_Works() List expectedPaymentProviders = [ - new() { ProviderType = ProviderType.Stripe, ExcludedPaymentMethodTypes = ["string"] }, + new() + { + ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }, ]; Assert.NotNull(deserialized.PaymentProviders); @@ -416,6 +516,7 @@ public void Validation_Works() new() { ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -465,6 +566,27 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PaymentConfiguration + { + PaymentProviders = + [ + new() + { + ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }; + + PaymentConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class PaymentProviderTest : TestBase @@ -475,13 +597,16 @@ public void FieldRoundtrip_Works() var model = new PaymentProvider { ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; ApiEnum expectedProviderType = ProviderType.Stripe; + string expectedDefaultSharedPaymentToken = "default_shared_payment_token"; List expectedExcludedPaymentMethodTypes = ["string"]; Assert.Equal(expectedProviderType, model.ProviderType); + Assert.Equal(expectedDefaultSharedPaymentToken, model.DefaultSharedPaymentToken); Assert.NotNull(model.ExcludedPaymentMethodTypes); Assert.Equal( expectedExcludedPaymentMethodTypes.Count, @@ -502,6 +627,7 @@ public void SerializationRoundtrip_Works() var model = new PaymentProvider { ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -520,6 +646,7 @@ public void FieldRoundtripThroughSerialization_Works() var model = new PaymentProvider { ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -531,9 +658,11 @@ public void FieldRoundtripThroughSerialization_Works() Assert.NotNull(deserialized); ApiEnum expectedProviderType = ProviderType.Stripe; + string expectedDefaultSharedPaymentToken = "default_shared_payment_token"; List expectedExcludedPaymentMethodTypes = ["string"]; Assert.Equal(expectedProviderType, deserialized.ProviderType); + Assert.Equal(expectedDefaultSharedPaymentToken, deserialized.DefaultSharedPaymentToken); Assert.NotNull(deserialized.ExcludedPaymentMethodTypes); Assert.Equal( expectedExcludedPaymentMethodTypes.Count, @@ -554,6 +683,7 @@ public void Validation_Works() var model = new PaymentProvider { ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -563,7 +693,11 @@ public void Validation_Works() [Fact] public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { - var model = new PaymentProvider { ProviderType = ProviderType.Stripe }; + var model = new PaymentProvider + { + ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + }; Assert.Null(model.ExcludedPaymentMethodTypes); Assert.False(model.RawData.ContainsKey("excluded_payment_method_types")); @@ -572,7 +706,11 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNonNullablePropertiesUnsetValidation_Works() { - var model = new PaymentProvider { ProviderType = ProviderType.Stripe }; + var model = new PaymentProvider + { + ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + }; model.Validate(); } @@ -583,6 +721,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() var model = new PaymentProvider { ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", // Null should be interpreted as omitted for these properties ExcludedPaymentMethodTypes = null, @@ -598,6 +737,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() var model = new PaymentProvider { ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", // Null should be interpreted as omitted for these properties ExcludedPaymentMethodTypes = null, @@ -605,6 +745,75 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new PaymentProvider + { + ProviderType = ProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }; + + Assert.Null(model.DefaultSharedPaymentToken); + Assert.False(model.RawData.ContainsKey("default_shared_payment_token")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new PaymentProvider + { + ProviderType = ProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new PaymentProvider + { + ProviderType = ProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + + DefaultSharedPaymentToken = null, + }; + + Assert.Null(model.DefaultSharedPaymentToken); + Assert.True(model.RawData.ContainsKey("default_shared_payment_token")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new PaymentProvider + { + ProviderType = ProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + + DefaultSharedPaymentToken = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PaymentProvider + { + ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }; + + PaymentProvider copied = new(model); + + Assert.Equal(model, copied); + } } public class ProviderTypeTest : TestBase @@ -671,6 +880,7 @@ public class CustomerCreateParamsPaymentProviderTest : TestBase [InlineData(CustomerCreateParamsPaymentProvider.StripeCharge)] [InlineData(CustomerCreateParamsPaymentProvider.StripeInvoice)] [InlineData(CustomerCreateParamsPaymentProvider.Netsuite)] + [InlineData(CustomerCreateParamsPaymentProvider.NetsuiteAmpersand)] public void Validation_Works(CustomerCreateParamsPaymentProvider rawValue) { // force implicit conversion because Theory can't do that for us @@ -695,6 +905,7 @@ public void InvalidEnumValidationThrows_Works() [InlineData(CustomerCreateParamsPaymentProvider.StripeCharge)] [InlineData(CustomerCreateParamsPaymentProvider.StripeInvoice)] [InlineData(CustomerCreateParamsPaymentProvider.Netsuite)] + [InlineData(CustomerCreateParamsPaymentProvider.NetsuiteAmpersand)] public void SerializationRoundtrip_Works(CustomerCreateParamsPaymentProvider rawValue) { // force implicit conversion because Theory can't do that for us @@ -977,6 +1188,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 +1296,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 +1404,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..bbd2d5717 100644 --- a/src/Orb.Tests/Models/Customers/CustomerListPageResponseTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerListPageResponseTest.cs @@ -88,6 +88,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -169,6 +170,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -269,6 +271,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -367,6 +370,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -455,6 +459,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -555,6 +560,7 @@ public void Validation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -567,4 +573,99 @@ 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, + DefaultSharedPaymentToken = "default_shared_payment_token", + 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..8e50bc9b3 100644 --- a/src/Orb.Tests/Models/Customers/CustomerTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerTest.cs @@ -82,6 +82,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -156,6 +157,7 @@ public void FieldRoundtrip_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -271,6 +273,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -356,6 +359,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -437,6 +441,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -552,6 +557,7 @@ public void Validation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -809,6 +815,91 @@ 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, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }, + ReportingConfiguration = new(true), + }; + + Customer copied = new(model); + + Assert.Equal(model, copied); + } } public class HierarchyTest : TestBase @@ -900,6 +991,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 @@ -910,6 +1015,7 @@ public class CustomerPaymentProviderTest : TestBase [InlineData(CustomerPaymentProvider.StripeCharge)] [InlineData(CustomerPaymentProvider.StripeInvoice)] [InlineData(CustomerPaymentProvider.Netsuite)] + [InlineData(CustomerPaymentProvider.NetsuiteAmpersand)] public void Validation_Works(CustomerPaymentProvider rawValue) { // force implicit conversion because Theory can't do that for us @@ -935,6 +1041,7 @@ public void InvalidEnumValidationThrows_Works() [InlineData(CustomerPaymentProvider.StripeCharge)] [InlineData(CustomerPaymentProvider.StripeInvoice)] [InlineData(CustomerPaymentProvider.Netsuite)] + [InlineData(CustomerPaymentProvider.NetsuiteAmpersand)] public void SerializationRoundtrip_Works(CustomerPaymentProvider rawValue) { // force implicit conversion because Theory can't do that for us @@ -1086,6 +1193,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 +1288,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 @@ -1167,6 +1309,7 @@ public class AccountingProviderProviderTypeTest : TestBase [Theory] [InlineData(AccountingProviderProviderType.Quickbooks)] [InlineData(AccountingProviderProviderType.Netsuite)] + [InlineData(AccountingProviderProviderType.NetsuiteAmpersand)] public void Validation_Works(AccountingProviderProviderType rawValue) { // force implicit conversion because Theory can't do that for us @@ -1189,6 +1332,7 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData(AccountingProviderProviderType.Quickbooks)] [InlineData(AccountingProviderProviderType.Netsuite)] + [InlineData(AccountingProviderProviderType.NetsuiteAmpersand)] public void SerializationRoundtrip_Works(AccountingProviderProviderType rawValue) { // force implicit conversion because Theory can't do that for us @@ -1230,6 +1374,7 @@ public void FieldRoundtrip_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1240,6 +1385,7 @@ public void FieldRoundtrip_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ]; @@ -1262,6 +1408,7 @@ public void SerializationRoundtrip_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1286,6 +1433,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1303,6 +1451,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ]; @@ -1325,6 +1474,7 @@ public void Validation_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1374,6 +1524,27 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerPaymentConfiguration + { + PaymentProviders = + [ + new() + { + ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }; + + CustomerPaymentConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerPaymentConfigurationPaymentProviderTest : TestBase @@ -1384,6 +1555,7 @@ public void FieldRoundtrip_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -1391,9 +1563,11 @@ public void FieldRoundtrip_Works() string, CustomerPaymentConfigurationPaymentProviderProviderType > expectedProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe; + string expectedDefaultSharedPaymentToken = "default_shared_payment_token"; List expectedExcludedPaymentMethodTypes = ["string"]; Assert.Equal(expectedProviderType, model.ProviderType); + Assert.Equal(expectedDefaultSharedPaymentToken, model.DefaultSharedPaymentToken); Assert.NotNull(model.ExcludedPaymentMethodTypes); Assert.Equal( expectedExcludedPaymentMethodTypes.Count, @@ -1414,6 +1588,7 @@ public void SerializationRoundtrip_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -1432,6 +1607,7 @@ public void FieldRoundtripThroughSerialization_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -1446,9 +1622,11 @@ public void FieldRoundtripThroughSerialization_Works() string, CustomerPaymentConfigurationPaymentProviderProviderType > expectedProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe; + string expectedDefaultSharedPaymentToken = "default_shared_payment_token"; List expectedExcludedPaymentMethodTypes = ["string"]; Assert.Equal(expectedProviderType, deserialized.ProviderType); + Assert.Equal(expectedDefaultSharedPaymentToken, deserialized.DefaultSharedPaymentToken); Assert.NotNull(deserialized.ExcludedPaymentMethodTypes); Assert.Equal( expectedExcludedPaymentMethodTypes.Count, @@ -1469,6 +1647,7 @@ public void Validation_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -1481,6 +1660,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", }; Assert.Null(model.ExcludedPaymentMethodTypes); @@ -1493,6 +1673,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", }; model.Validate(); @@ -1504,6 +1685,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", // Null should be interpreted as omitted for these properties ExcludedPaymentMethodTypes = null, @@ -1519,6 +1701,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", // Null should be interpreted as omitted for these properties ExcludedPaymentMethodTypes = null, @@ -1526,6 +1709,75 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CustomerPaymentConfigurationPaymentProvider + { + ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }; + + Assert.Null(model.DefaultSharedPaymentToken); + Assert.False(model.RawData.ContainsKey("default_shared_payment_token")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new CustomerPaymentConfigurationPaymentProvider + { + ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CustomerPaymentConfigurationPaymentProvider + { + ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + + DefaultSharedPaymentToken = null, + }; + + Assert.Null(model.DefaultSharedPaymentToken); + Assert.True(model.RawData.ContainsKey("default_shared_payment_token")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new CustomerPaymentConfigurationPaymentProvider + { + ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + + DefaultSharedPaymentToken = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerPaymentConfigurationPaymentProvider + { + ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }; + + CustomerPaymentConfigurationPaymentProvider copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerPaymentConfigurationPaymentProviderProviderTypeTest : TestBase @@ -1632,4 +1884,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..db9beaba3 100644 --- a/src/Orb.Tests/Models/Customers/CustomerUpdateByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerUpdateByExternalIDParamsTest.cs @@ -59,6 +59,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -134,6 +135,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -327,6 +329,92 @@ 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, + DefaultSharedPaymentToken = "default_shared_payment_token", + 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 @@ -342,6 +430,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -353,6 +442,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ]; @@ -376,6 +466,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -402,6 +493,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -421,6 +513,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ]; @@ -444,6 +537,7 @@ public void Validation_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -493,6 +587,28 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerUpdateByExternalIDParamsPaymentConfiguration + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }; + + CustomerUpdateByExternalIDParamsPaymentConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderTest : TestBase @@ -504,6 +620,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -512,9 +629,11 @@ public void FieldRoundtrip_Works() CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType > expectedProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe; + string expectedDefaultSharedPaymentToken = "default_shared_payment_token"; List expectedExcludedPaymentMethodTypes = ["string"]; Assert.Equal(expectedProviderType, model.ProviderType); + Assert.Equal(expectedDefaultSharedPaymentToken, model.DefaultSharedPaymentToken); Assert.NotNull(model.ExcludedPaymentMethodTypes); Assert.Equal( expectedExcludedPaymentMethodTypes.Count, @@ -536,6 +655,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -556,6 +676,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -572,9 +693,11 @@ public void FieldRoundtripThroughSerialization_Works() CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType > expectedProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe; + string expectedDefaultSharedPaymentToken = "default_shared_payment_token"; List expectedExcludedPaymentMethodTypes = ["string"]; Assert.Equal(expectedProviderType, deserialized.ProviderType); + Assert.Equal(expectedDefaultSharedPaymentToken, deserialized.DefaultSharedPaymentToken); Assert.NotNull(deserialized.ExcludedPaymentMethodTypes); Assert.Equal( expectedExcludedPaymentMethodTypes.Count, @@ -596,6 +719,7 @@ public void Validation_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -609,6 +733,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", }; Assert.Null(model.ExcludedPaymentMethodTypes); @@ -622,6 +747,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", }; model.Validate(); @@ -634,6 +760,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", // Null should be interpreted as omitted for these properties ExcludedPaymentMethodTypes = null, @@ -650,6 +777,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", // Null should be interpreted as omitted for these properties ExcludedPaymentMethodTypes = null, @@ -657,6 +785,80 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider + { + ProviderType = + CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }; + + Assert.Null(model.DefaultSharedPaymentToken); + Assert.False(model.RawData.ContainsKey("default_shared_payment_token")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider + { + ProviderType = + CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider + { + ProviderType = + CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + + DefaultSharedPaymentToken = null, + }; + + Assert.Null(model.DefaultSharedPaymentToken); + Assert.True(model.RawData.ContainsKey("default_shared_payment_token")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider + { + ProviderType = + CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + + DefaultSharedPaymentToken = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider + { + ProviderType = + CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }; + + CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderTypeTest @@ -746,6 +948,7 @@ public class CustomerUpdateByExternalIDParamsPaymentProviderTest : TestBase [InlineData(CustomerUpdateByExternalIDParamsPaymentProvider.StripeCharge)] [InlineData(CustomerUpdateByExternalIDParamsPaymentProvider.StripeInvoice)] [InlineData(CustomerUpdateByExternalIDParamsPaymentProvider.Netsuite)] + [InlineData(CustomerUpdateByExternalIDParamsPaymentProvider.NetsuiteAmpersand)] public void Validation_Works(CustomerUpdateByExternalIDParamsPaymentProvider rawValue) { // force implicit conversion because Theory can't do that for us @@ -770,6 +973,7 @@ public void InvalidEnumValidationThrows_Works() [InlineData(CustomerUpdateByExternalIDParamsPaymentProvider.StripeCharge)] [InlineData(CustomerUpdateByExternalIDParamsPaymentProvider.StripeInvoice)] [InlineData(CustomerUpdateByExternalIDParamsPaymentProvider.Netsuite)] + [InlineData(CustomerUpdateByExternalIDParamsPaymentProvider.NetsuiteAmpersand)] public void SerializationRoundtrip_Works( CustomerUpdateByExternalIDParamsPaymentProvider rawValue ) @@ -1117,6 +1321,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 +1457,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 +1593,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..c7087f5c9 100644 --- a/src/Orb.Tests/Models/Customers/CustomerUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerUpdateParamsTest.cs @@ -59,6 +59,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -134,6 +135,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -322,6 +324,92 @@ 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, + DefaultSharedPaymentToken = "default_shared_payment_token", + 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 @@ -337,6 +425,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -348,6 +437,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ]; @@ -371,6 +461,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -396,6 +487,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -414,6 +506,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ]; @@ -437,6 +530,7 @@ public void Validation_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -486,6 +580,28 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerUpdateParamsPaymentConfiguration + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }; + + CustomerUpdateParamsPaymentConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerUpdateParamsPaymentConfigurationPaymentProviderTest : TestBase @@ -497,6 +613,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -505,9 +622,11 @@ public void FieldRoundtrip_Works() CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType > expectedProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe; + string expectedDefaultSharedPaymentToken = "default_shared_payment_token"; List expectedExcludedPaymentMethodTypes = ["string"]; Assert.Equal(expectedProviderType, model.ProviderType); + Assert.Equal(expectedDefaultSharedPaymentToken, model.DefaultSharedPaymentToken); Assert.NotNull(model.ExcludedPaymentMethodTypes); Assert.Equal( expectedExcludedPaymentMethodTypes.Count, @@ -529,6 +648,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -549,6 +669,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -565,9 +686,11 @@ public void FieldRoundtripThroughSerialization_Works() CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType > expectedProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe; + string expectedDefaultSharedPaymentToken = "default_shared_payment_token"; List expectedExcludedPaymentMethodTypes = ["string"]; Assert.Equal(expectedProviderType, deserialized.ProviderType); + Assert.Equal(expectedDefaultSharedPaymentToken, deserialized.DefaultSharedPaymentToken); Assert.NotNull(deserialized.ExcludedPaymentMethodTypes); Assert.Equal( expectedExcludedPaymentMethodTypes.Count, @@ -589,6 +712,7 @@ public void Validation_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -602,6 +726,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", }; Assert.Null(model.ExcludedPaymentMethodTypes); @@ -615,6 +740,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", }; model.Validate(); @@ -627,6 +753,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", // Null should be interpreted as omitted for these properties ExcludedPaymentMethodTypes = null, @@ -643,6 +770,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", // Null should be interpreted as omitted for these properties ExcludedPaymentMethodTypes = null, @@ -650,6 +778,80 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CustomerUpdateParamsPaymentConfigurationPaymentProvider + { + ProviderType = + CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }; + + Assert.Null(model.DefaultSharedPaymentToken); + Assert.False(model.RawData.ContainsKey("default_shared_payment_token")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new CustomerUpdateParamsPaymentConfigurationPaymentProvider + { + ProviderType = + CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CustomerUpdateParamsPaymentConfigurationPaymentProvider + { + ProviderType = + CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + + DefaultSharedPaymentToken = null, + }; + + Assert.Null(model.DefaultSharedPaymentToken); + Assert.True(model.RawData.ContainsKey("default_shared_payment_token")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new CustomerUpdateParamsPaymentConfigurationPaymentProvider + { + ProviderType = + CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + + DefaultSharedPaymentToken = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerUpdateParamsPaymentConfigurationPaymentProvider + { + ProviderType = + CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }; + + CustomerUpdateParamsPaymentConfigurationPaymentProvider copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderTypeTest : TestBase @@ -718,6 +920,7 @@ public class CustomerUpdateParamsPaymentProviderTest : TestBase [InlineData(CustomerUpdateParamsPaymentProvider.StripeCharge)] [InlineData(CustomerUpdateParamsPaymentProvider.StripeInvoice)] [InlineData(CustomerUpdateParamsPaymentProvider.Netsuite)] + [InlineData(CustomerUpdateParamsPaymentProvider.NetsuiteAmpersand)] public void Validation_Works(CustomerUpdateParamsPaymentProvider rawValue) { // force implicit conversion because Theory can't do that for us @@ -742,6 +945,7 @@ public void InvalidEnumValidationThrows_Works() [InlineData(CustomerUpdateParamsPaymentProvider.StripeCharge)] [InlineData(CustomerUpdateParamsPaymentProvider.StripeInvoice)] [InlineData(CustomerUpdateParamsPaymentProvider.Netsuite)] + [InlineData(CustomerUpdateParamsPaymentProvider.NetsuiteAmpersand)] public void SerializationRoundtrip_Works(CustomerUpdateParamsPaymentProvider rawValue) { // force implicit conversion because Theory can't do that for us @@ -1071,6 +1275,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 +1409,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 +1543,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..de72f4453 100644 --- a/src/Orb.Tests/Models/Invoices/InvoicePayParamsTest.cs +++ b/src/Orb.Tests/Models/Invoices/InvoicePayParamsTest.cs @@ -8,20 +8,44 @@ public class InvoicePayParamsTest : TestBase [Fact] public void FieldRoundtrip_Works() { - var parameters = new InvoicePayParams { InvoiceID = "invoice_id" }; + var parameters = new InvoicePayParams + { + InvoiceID = "invoice_id", + SharedPaymentTokenID = "shared_payment_token_id", + }; string expectedInvoiceID = "invoice_id"; + string expectedSharedPaymentTokenID = "shared_payment_token_id"; Assert.Equal(expectedInvoiceID, parameters.InvoiceID); + Assert.Equal(expectedSharedPaymentTokenID, parameters.SharedPaymentTokenID); } [Fact] public void Url_Works() { - InvoicePayParams parameters = new() { InvoiceID = "invoice_id" }; + InvoicePayParams parameters = new() + { + InvoiceID = "invoice_id", + SharedPaymentTokenID = "shared_payment_token_id", + }; var url = parameters.Url(new() { ApiKey = "My API Key" }); 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", + SharedPaymentTokenID = "shared_payment_token_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..016a2a7c1 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/MutatedSubscriptionTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/MutatedSubscriptionTest.cs @@ -131,6 +131,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -408,6 +409,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -475,6 +477,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 +563,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -622,9 +631,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 +915,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -977,6 +997,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 +1358,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1413,6 +1440,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"), @@ -1632,6 +1665,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1909,6 +1943,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1976,6 +2011,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 +2095,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2121,9 +2163,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 +2442,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2459,6 +2512,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 +2865,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2875,6 +2935,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"), @@ -3156,6 +3222,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -3433,6 +3500,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3500,6 +3568,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 +3654,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3647,9 +3722,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 +4006,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4002,6 +4088,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 +4449,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4438,6 +4531,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"), @@ -4667,6 +4766,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -4944,6 +5044,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5011,6 +5112,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 +5198,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5158,9 +5266,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 +5550,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5513,6 +5632,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 +5993,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5949,6 +6075,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"), @@ -6175,6 +6307,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -6452,6 +6585,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6519,6 +6653,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 +6737,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6664,9 +6805,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 +7084,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7002,6 +7154,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 +7507,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7418,6 +7577,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"), @@ -7708,6 +7873,7 @@ public void Validation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -7985,6 +8151,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8052,6 +8219,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 +8305,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8199,9 +8373,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 +8657,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8554,6 +8739,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 +9100,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8990,6 +9182,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"), @@ -9213,6 +9411,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -9490,6 +9689,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9557,6 +9757,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 +9843,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9704,9 +9911,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() @@ -9843,6 +10060,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -10120,6 +10338,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10187,6 +10406,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 +10492,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10334,9 +10560,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() @@ -10472,6 +10708,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -10749,6 +10986,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10816,6 +11054,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 +11140,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10963,9 +11208,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() @@ -11104,6 +11359,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -11381,6 +11637,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11448,6 +11705,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 +11791,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11595,9 +11859,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 +11889,1546 @@ 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, + DefaultSharedPaymentToken = "default_shared_payment_token", + 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..6fb9972a1 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyResponseTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeApplyResponseTest.cs @@ -141,6 +141,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -420,6 +421,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -488,6 +490,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 +578,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -638,9 +647,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 +946,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1010,6 +1030,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 +1406,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1463,6 +1490,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"), @@ -1692,6 +1725,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1969,6 +2003,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2036,6 +2071,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 +2157,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2183,9 +2225,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 +2509,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2538,6 +2591,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 +2952,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2974,6 +3034,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"), @@ -3223,6 +3289,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -3502,6 +3569,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3570,6 +3638,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 +3726,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3720,9 +3795,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 +4094,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4092,6 +4178,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 +4554,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4545,6 +4638,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"), @@ -4791,6 +4890,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -5070,6 +5170,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5138,6 +5239,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 +5327,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5288,9 +5396,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 +5695,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5660,6 +5779,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 +6155,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6113,6 +6239,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"), @@ -6349,6 +6481,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -6626,6 +6759,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6693,6 +6827,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 +6913,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6840,9 +6981,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 +7265,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7195,6 +7347,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 +7708,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7631,6 +7790,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"), @@ -7880,6 +8045,7 @@ public void Validation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -8159,6 +8325,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8227,6 +8394,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 +8482,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8377,9 +8551,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 +8850,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8749,6 +8934,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 +9310,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9202,6 +9394,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"), @@ -9442,6 +9640,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -9721,6 +9920,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9789,6 +9989,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 +10077,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9939,9 +10146,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 +10445,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10311,6 +10529,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 +10905,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10764,6 +10989,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"), @@ -11009,6 +11240,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -11288,6 +11520,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11356,6 +11589,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 +11677,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11506,9 +11746,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 +12045,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11878,6 +12129,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 +12505,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12331,6 +12589,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"), @@ -12565,6 +12829,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -12844,6 +13109,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12912,6 +13178,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 +13266,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13062,9 +13335,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 +13634,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13434,6 +13718,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 +14094,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13887,6 +14178,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"), @@ -14139,6 +14436,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -14418,6 +14716,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14486,6 +14785,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 +14873,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14636,9 +14942,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 +15241,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15008,6 +15325,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 +15701,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15461,6 +15785,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 +15902,1603 @@ 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, + DefaultSharedPaymentToken = "default_shared_payment_token", + 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..e36fff5eb 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelResponseTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeCancelResponseTest.cs @@ -141,6 +141,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -420,6 +421,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -488,6 +490,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 +578,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -638,9 +647,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 +946,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1010,6 +1030,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 +1406,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1463,6 +1490,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"), @@ -1692,6 +1725,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1969,6 +2003,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2036,6 +2071,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 +2157,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2183,9 +2225,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 +2509,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2538,6 +2591,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 +2952,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2974,6 +3034,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"), @@ -3223,6 +3289,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -3502,6 +3569,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3570,6 +3638,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 +3726,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3720,9 +3795,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 +4094,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4092,6 +4178,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 +4554,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4545,6 +4638,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"), @@ -4791,6 +4890,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -5070,6 +5170,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5138,6 +5239,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 +5327,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5288,9 +5396,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 +5695,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5660,6 +5779,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 +6155,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6113,6 +6239,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"), @@ -6349,6 +6481,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -6626,6 +6759,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6693,6 +6827,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 +6913,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6840,9 +6981,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 +7265,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7195,6 +7347,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 +7708,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7631,6 +7790,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"), @@ -7880,6 +8045,7 @@ public void Validation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -8159,6 +8325,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8227,6 +8394,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 +8482,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8377,9 +8551,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 +8850,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8749,6 +8934,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 +9310,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9202,6 +9394,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"), @@ -9442,6 +9640,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -9721,6 +9920,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9789,6 +9989,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 +10077,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9939,9 +10146,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 +10445,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10311,6 +10529,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 +10905,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10764,6 +10989,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"), @@ -11009,6 +11240,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -11288,6 +11520,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11356,6 +11589,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 +11677,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11506,9 +11746,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 +12045,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11878,6 +12129,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 +12505,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12331,6 +12589,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"), @@ -12565,6 +12829,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -12844,6 +13109,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12912,6 +13178,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 +13266,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13062,9 +13335,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 +13634,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13434,6 +13718,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 +14094,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13887,6 +14178,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"), @@ -14139,6 +14436,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -14418,6 +14716,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14486,6 +14785,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 +14873,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14636,9 +14942,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 +15241,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15008,6 +15325,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 +15701,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15461,6 +15785,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 +15902,1603 @@ 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, + DefaultSharedPaymentToken = "default_shared_payment_token", + 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..5bc8fd260 100644 --- a/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponseTest.cs +++ b/src/Orb.Tests/Models/SubscriptionChanges/SubscriptionChangeRetrieveResponseTest.cs @@ -141,6 +141,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -420,6 +421,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -488,6 +490,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 +578,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -638,9 +647,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 +946,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1010,6 +1030,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 +1406,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -1463,6 +1490,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"), @@ -1692,6 +1725,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1969,6 +2003,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2036,6 +2071,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 +2157,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2183,9 +2225,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 +2509,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2538,6 +2591,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 +2952,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -2974,6 +3034,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"), @@ -3223,6 +3289,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -3502,6 +3569,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3570,6 +3638,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 +3726,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -3720,9 +3795,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 +4094,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4092,6 +4178,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 +4554,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -4545,6 +4638,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"), @@ -4791,6 +4890,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -5070,6 +5170,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5138,6 +5239,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 +5327,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5288,9 +5396,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 +5695,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -5660,6 +5779,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 +6155,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6113,6 +6239,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"), @@ -6349,6 +6481,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -6626,6 +6759,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6693,6 +6827,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 +6913,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -6840,9 +6981,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 +7265,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7195,6 +7347,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 +7708,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -7631,6 +7790,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"), @@ -7880,6 +8045,7 @@ public void Validation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -8159,6 +8325,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8227,6 +8394,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 +8482,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8377,9 +8551,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 +8850,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -8749,6 +8934,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 +9310,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9202,6 +9394,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"), @@ -9442,6 +9640,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -9721,6 +9920,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9789,6 +9989,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 +10077,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -9939,9 +10146,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 +10445,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10311,6 +10529,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 +10905,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -10764,6 +10989,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"), @@ -11009,6 +11240,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -11288,6 +11520,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11356,6 +11589,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 +11677,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11506,9 +11746,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 +12045,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -11878,6 +12129,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 +12505,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12331,6 +12589,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"), @@ -12565,6 +12829,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -12844,6 +13109,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -12912,6 +13178,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 +13266,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13062,9 +13335,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 +13634,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13434,6 +13718,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 +14094,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -13887,6 +14178,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"), @@ -14139,6 +14436,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -14418,6 +14716,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14486,6 +14785,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 +14873,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -14636,9 +14942,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 +15241,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15008,6 +15325,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 +15701,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new Models::PercentageDiscount() @@ -15461,6 +15785,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 +15902,1603 @@ 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, + DefaultSharedPaymentToken = "default_shared_payment_token", + 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..bc5d28d88 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionSubscriptionsTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionSubscriptionsTest.cs @@ -143,6 +143,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -420,6 +421,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -487,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() @@ -575,6 +583,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -642,9 +651,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() @@ -782,6 +801,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1059,6 +1079,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1126,6 +1147,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 +1239,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1279,9 +1307,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() @@ -1441,6 +1479,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1718,6 +1757,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1785,6 +1825,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 +1919,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1940,9 +1987,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() @@ -2100,6 +2157,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -2377,6 +2435,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2444,6 +2503,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 +2597,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2599,9 +2665,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() @@ -2746,6 +2822,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -3023,6 +3100,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3090,6 +3168,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 +3260,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3243,9 +3328,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() @@ -3405,6 +3500,7 @@ public void Validation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -3682,6 +3778,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3749,6 +3846,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 +3940,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3904,9 +4008,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 +4039,678 @@ 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, + DefaultSharedPaymentToken = "default_shared_payment_token", + 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..70fe670cd 100644 --- a/src/Orb.Tests/Models/Subscriptions/SubscriptionTest.cs +++ b/src/Orb.Tests/Models/Subscriptions/SubscriptionTest.cs @@ -130,6 +130,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -406,6 +407,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -473,6 +475,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 +565,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -624,9 +633,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() @@ -756,6 +775,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1030,6 +1050,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1097,6 +1118,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 +1201,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1241,9 +1269,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() @@ -1438,6 +1476,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1714,6 +1753,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1781,6 +1821,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 +1911,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1932,9 +1979,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() @@ -2075,6 +2132,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -2351,6 +2409,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2418,6 +2477,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 +2567,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2569,9 +2635,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() @@ -2708,6 +2784,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -2982,6 +3059,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3049,6 +3127,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 +3210,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3193,9 +3278,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() @@ -3399,6 +3494,7 @@ public void Validation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -3675,6 +3771,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3742,6 +3839,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 +3929,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3893,9 +3997,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 +4025,658 @@ 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, + DefaultSharedPaymentToken = "default_shared_payment_token", + 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..ad15fbf75 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() { @@ -119,7 +130,7 @@ public async Task Pay_Works() { var invoice = await this.client.Invoices.Pay( "invoice_id", - new(), + new() { SharedPaymentTokenID = "shared_payment_token_id" }, TestContext.Current.CancellationToken ); invoice.Validate(); 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..9c6cea903 100644 --- a/src/Orb/Core/ApiEnum.cs +++ b/src/Orb/Core/ApiEnum.cs @@ -11,19 +11,26 @@ namespace Orb.Core; /// /// In most cases you don't have to worry about this type and can rely on its implicit operators to /// wrap and unwrap enum values. -/// -/// -/// Returns this instance's raw value. -/// -/// This is usually only useful if this instance was deserialized from data that doesn't match the -/// expected type (), and you want to know that value. For example, if the -/// SDK is on an older version than the API, then the API may respond with new data types that the SDK is -/// unaware of. -/// /// -public record class ApiEnum(JsonElement Json) +public record class ApiEnum where TEnum : struct, Enum { + /// + /// Returns this instance's raw value. + /// + /// This is usually only useful if this instance was deserialized from data that doesn't match the + /// expected type (), and you want to know that value. For example, if the + /// SDK is on an older version than the API, then the API may respond with new data types that the SDK is + /// unaware of. + /// + /// + public JsonElement Json; + + public ApiEnum(JsonElement json) + { + Json = json; + } + /// /// Returns this instance's raw value. /// @@ -94,6 +101,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..cfa6b43c6 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 . @@ -22,7 +22,8 @@ public struct ClientOptions() /// /// The HTTP client to use for making requests in the SDK. /// - public HttpClient HttpClient { get; set; } = new(); + public HttpClient HttpClient { get; set; } = + new(new HttpClientHandler() { AutomaticDecompression = DecompressionMethods.Available }); Lazy _baseUrl = new(() => Environment.GetEnvironmentVariable("ORB_BASE_URL") ?? EnvironmentUrl.Production @@ -71,7 +72,7 @@ public string BaseUrl /// Defaults to 2 when null. Set to 0 to /// disable retries, which also ignores API instructions to retry. /// - public int? MaxRetries { get; set; } + public int? MaxRetries { get; set; } = null; /// /// Sets the maximum time allowed for a complete HTTP call, not including retries. @@ -81,7 +82,7 @@ public string BaseUrl /// /// Defaults to TimeSpan.FromMinutes(1) when null. /// - public TimeSpan? Timeout { get; set; } + public TimeSpan? Timeout { get; set; } = null; Lazy _apiKey = new(() => Environment.GetEnvironmentVariable("ORB_API_KEY") diff --git a/src/Orb/Core/DecompressionMethods.cs b/src/Orb/Core/DecompressionMethods.cs new file mode 100644 index 000000000..3856958b9 --- /dev/null +++ b/src/Orb/Core/DecompressionMethods.cs @@ -0,0 +1,49 @@ +using System.IO; +using System.IO.Compression; +using Net = System.Net; + +namespace Orb.Core; + +static class DecompressionMethods +{ + internal static readonly Net::DecompressionMethods Available; + + static DecompressionMethods() + { + try + { + // Minimal valid GZip payload (empty body). + var gzipPayload = new byte[] + { + 0x1f, + 0x8b, + 0x08, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x03, + 0x03, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + 0x00, + }; + using var memoryStream = new MemoryStream(gzipPayload); + using var gzipStream = new GZipStream(memoryStream, CompressionMode.Decompress); + gzipStream.CopyTo(Stream.Null); + Available = Net::DecompressionMethods.GZip; + } + catch + { + Available = Net::DecompressionMethods.None; + } + } +} 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..e92c3bb8d 100644 --- a/src/Orb/Core/HttpResponse.cs +++ b/src/Orb/Core/HttpResponse.cs @@ -4,6 +4,7 @@ using System.IO; using System.Net; using System.Net.Http; +using System.Runtime.CompilerServices; using System.Text.Json; using System.Threading.Tasks; using Orb.Exceptions; @@ -39,6 +40,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 +110,7 @@ public void Dispose() } } -public sealed class HttpResponse : global::Orb.Core.HttpResponse +public sealed class HttpResponse : HttpResponse { readonly Func> _deserialize; @@ -106,7 +121,7 @@ internal HttpResponse(Func> deserialize) [SetsRequiredMembers] internal HttpResponse( - global::Orb.Core.HttpResponse response, + HttpResponse response, Func> deserialize ) : this(deserialize) @@ -125,7 +140,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 +153,7 @@ internal StreamingHttpResponse( [SetsRequiredMembers] internal StreamingHttpResponse( - global::Orb.Core.HttpResponse response, + HttpResponse response, Func> enumerate ) : this(enumerate) @@ -147,12 +162,17 @@ internal StreamingHttpResponse( this.CancellationToken = response.CancellationToken; } - public IAsyncEnumerable Enumerate(Threading::CancellationToken cancellationToken = default) + public async IAsyncEnumerable Enumerate( + [EnumeratorCancellationAttribute] Threading::CancellationToken cancellationToken = default + ) { using var cts = Threading::CancellationTokenSource.CreateLinkedTokenSource( this.CancellationToken, cancellationToken ); - return this._enumerate(cts.Token); + await foreach (var item in this._enumerate(cts.Token)) + { + yield return item; + } } } diff --git a/src/Orb/Core/JsonDictionary.cs b/src/Orb/Core/JsonDictionary.cs index 461dc7931..45489fbf1 100644 --- a/src/Orb/Core/JsonDictionary.cs +++ b/src/Orb/Core/JsonDictionary.cs @@ -11,15 +11,15 @@ namespace Orb.Core; ///

/// A dictionary that holds JSON data. /// -/// It can be mutated and then frozen once no more mutations are expected. This -/// is useful for allowing the dictionary to be modified by a class's init -/// properties, but then preventing it from being modified afterwards. +/// It can be mutated and then frozen once no more mutations are expected. +/// This is useful for allowing the dictionary to be modified by a class's +/// init properties, but then preventing it from being modified afterwards. /// /// It also caches data deserialization for performance. /// sealed class JsonDictionary { - IDictionary _rawData; + IReadOnlyDictionary _rawData; readonly ConcurrentDictionary _deserializedData; @@ -38,19 +38,19 @@ Dictionary MutableRawData public JsonDictionary() { _rawData = new Dictionary(); - _deserializedData = []; + _deserializedData = new(); } public JsonDictionary(IReadOnlyDictionary dictionary) { _rawData = Enumerable.ToDictionary(dictionary, (e) => e.Key, (e) => e.Value); - _deserializedData = []; + _deserializedData = new(); } public JsonDictionary(FrozenDictionary dictionary) { _rawData = dictionary; - _deserializedData = []; + _deserializedData = new(); } public JsonDictionary(JsonDictionary dictionary) @@ -94,17 +94,7 @@ public T GetNotNullClass(string key) { throw new OrbInvalidDataException($"'{key}' cannot be absent"); } - T deserialized; - try - { - deserialized = - JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new OrbInvalidDataException($"'{key}' cannot be null"); - } - catch (JsonException e) - { - throw new OrbInvalidDataException($"'{key}' must be of type {typeof(T).FullName}", e); - } + T deserialized = WrappedJsonSerializer.GetNotNullClass(element, key); _deserializedData[key] = deserialized; return deserialized; } @@ -120,17 +110,7 @@ public T GetNotNullStruct(string key) { throw new OrbInvalidDataException($"'{key}' cannot be absent"); } - T deserialized; - try - { - deserialized = - JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new OrbInvalidDataException($"'{key}' cannot be null"); - } - catch (JsonException e) - { - throw new OrbInvalidDataException($"'{key}' must be of type {typeof(T).FullName}", e); - } + T deserialized = WrappedJsonSerializer.GetNotNullStruct(element, key); _deserializedData[key] = deserialized; return deserialized; } @@ -147,15 +127,7 @@ public T GetNotNullStruct(string key) _deserializedData[key] = null; return null; } - T? deserialized; - try - { - deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - catch (JsonException e) - { - throw new OrbInvalidDataException($"'{key}' must be of type {typeof(T).FullName}", e); - } + T? deserialized = WrappedJsonSerializer.GetNullableClass(element, key); _deserializedData[key] = deserialized; return deserialized; } @@ -172,21 +144,16 @@ public T GetNotNullStruct(string key) _deserializedData[key] = null; return null; } - T? deserialized; - try - { - deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - } - catch (JsonException e) - { - throw new OrbInvalidDataException($"'{key}' must be of type {typeof(T).FullName}", e); - } + T? deserialized = WrappedJsonSerializer.GetNullableStruct(element, key); _deserializedData[key] = deserialized; return deserialized; } 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..d2c45e0f3 100644 --- a/src/Orb/Core/MultipartJsonDictionary.cs +++ b/src/Orb/Core/MultipartJsonDictionary.cs @@ -11,15 +11,15 @@ namespace Orb.Core; /// /// A dictionary that holds mixed JSON and binary content. /// -/// It can be mutated and then frozen once no more mutations are expected. This -/// is useful for allowing the dictionary to be modified by a class's init -/// properties, but then preventing it from being modified afterwards. +/// It can be mutated and then frozen once no more mutations are expected. +/// This is useful for allowing the dictionary to be modified by a class's +/// init properties, but then preventing it from being modified afterwards. /// /// It also caches data deserialization for performance. /// sealed class MultipartJsonDictionary { - IDictionary _rawData; + IReadOnlyDictionary _rawData; readonly ConcurrentDictionary _deserializedData; @@ -38,19 +38,19 @@ Dictionary MutableRawData public MultipartJsonDictionary() { _rawData = new Dictionary(); - _deserializedData = []; + _deserializedData = new(); } public MultipartJsonDictionary(IReadOnlyDictionary dictionary) { _rawData = Enumerable.ToDictionary(dictionary, (e) => e.Key, (e) => e.Value); - _deserializedData = []; + _deserializedData = new(); } public MultipartJsonDictionary(FrozenDictionary dictionary) { _rawData = dictionary; - _deserializedData = []; + _deserializedData = new(); } public MultipartJsonDictionary(MultipartJsonDictionary dictionary) @@ -97,17 +97,7 @@ public T GetNotNullClass(string key) { throw new OrbInvalidDataException($"'{key}' cannot be absent"); } - T deserialized; - try - { - deserialized = - MultipartJsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new OrbInvalidDataException($"'{key}' cannot be null"); - } - catch (JsonException e) - { - throw new OrbInvalidDataException($"'{key}' must be of type {typeof(T).FullName}", e); - } + T? deserialized = WrappedMultipartJsonSerializer.GetNotNullClass(element, key); _deserializedData[key] = deserialized; return deserialized; } @@ -123,17 +113,7 @@ public T GetNotNullStruct(string key) { throw new OrbInvalidDataException($"'{key}' cannot be absent"); } - T deserialized; - try - { - deserialized = - MultipartJsonSerializer.Deserialize(element, ModelBase.SerializerOptions) - ?? throw new OrbInvalidDataException($"'{key}' cannot be null"); - } - catch (JsonException e) - { - throw new OrbInvalidDataException($"'{key}' must be of type {typeof(T).FullName}", e); - } + T deserialized = WrappedMultipartJsonSerializer.GetNotNullStruct(element, key); _deserializedData[key] = deserialized; return deserialized; } @@ -150,18 +130,7 @@ public T GetNotNullStruct(string key) _deserializedData[key] = null; return null; } - T? deserialized; - try - { - deserialized = MultipartJsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - } - catch (JsonException e) - { - throw new OrbInvalidDataException($"'{key}' must be of type {typeof(T).FullName}", e); - } + T? deserialized = WrappedMultipartJsonSerializer.GetNullableClass(element, key); _deserializedData[key] = deserialized; return deserialized; } @@ -178,19 +147,42 @@ public T GetNotNullStruct(string key) _deserializedData[key] = null; return null; } - T? deserialized; - try + T? deserialized = WrappedMultipartJsonSerializer.GetNullableStruct(element, 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) { - deserialized = MultipartJsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + return false; } - catch (JsonException e) + + foreach (var item in _rawData) { - throw new OrbInvalidDataException($"'{key}' must be of type {typeof(T).FullName}", e); + if (!other._rawData.TryGetValue(item.Key, out var otherValue)) + { + return false; + } + + if (!MultipartJsonElement.DeepEquals(item.Value, otherValue)) + { + return false; + } } - _deserializedData[key] = deserialized; - return deserialized; + + return true; + } + + public override int GetHashCode() + { + return 0; } } diff --git a/src/Orb/Core/MultipartJsonElement.cs b/src/Orb/Core/MultipartJsonElement.cs index e676ca7c4..8f49340ec 100644 --- a/src/Orb/Core/MultipartJsonElement.cs +++ b/src/Orb/Core/MultipartJsonElement.cs @@ -14,13 +14,13 @@ namespace Orb.Core; /// /// Use to construct or read instances of this class. ///
-public readonly struct MultipartJsonElement() +public readonly struct MultipartJsonElement { /// /// A with placeholders /// for . /// - internal JsonElement Json { get; init; } + internal JsonElement Json { get; init; } = default; /// /// A dictionary from placeholder string in the JSON to @@ -30,6 +30,122 @@ public readonly struct MultipartJsonElement() FrozenDictionary.ToFrozenDictionary(new Dictionary()); public static implicit operator MultipartJsonElement(JsonElement json) => new() { Json = json }; + + public MultipartJsonElement() { } + + 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"); + } + } } /// @@ -61,7 +177,7 @@ internal static Dictionary BinaryContents static readonly ThreadLocal< Dictionary - > MultipartSerializerOptionsCache = new(() => []); + > MultipartSerializerOptionsCache = new(() => new()); static readonly JsonSerializerOptions DefaultMultipartSerializerOptions = MultipartSerializerOptions(new()); @@ -92,7 +208,7 @@ public static MultipartJsonElement SerializeToElement( var previousBinaryContents = CurrentBinaryContents.Value; try { - CurrentBinaryContents.Value = []; + CurrentBinaryContents.Value = new(); var element = JsonSerializer.SerializeToElement( value, MultipartSerializerOptions(options) @@ -135,11 +251,11 @@ public static MultipartFormDataContent Serialize( JsonSerializerOptions? options = null ) { - MultipartFormDataContent formDataContent = []; + MultipartFormDataContent formDataContent = new(); var multipartElement = MultipartJsonSerializer.SerializeToElement(value, options); void SerializeParts(string name, JsonElement element) { - HttpContent content; + HttpContent? content; string? fileName = null; switch (element.ValueKind) { @@ -188,17 +304,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..f96b4f882 100644 --- a/src/Orb/Core/ParamsBase.cs +++ b/src/Orb/Core/ParamsBase.cs @@ -151,9 +151,9 @@ JsonElement element } } - protected string QueryString(ClientOptions options) + internal string QueryString(ClientOptions options) { - NameValueCollection collection = []; + NameValueCollection collection = new(); foreach (var item in this.RawQueryData) { ParamsBase.AddQueryElementToCollection(collection, item.Key, item.Value); @@ -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; @@ -262,5 +262,10 @@ static Runtime GetRuntime() }; } - readonly record struct Runtime(string Name, string Version); + readonly record struct Runtime + { + public string Name { get; init; } + + public string Version { get; init; } + } } diff --git a/src/Orb/Core/WrappedJsonSerializer.cs b/src/Orb/Core/WrappedJsonSerializer.cs new file mode 100644 index 000000000..105677a4c --- /dev/null +++ b/src/Orb/Core/WrappedJsonSerializer.cs @@ -0,0 +1,75 @@ +using System.Text.Json; +using Orb.Exceptions; + +namespace Orb.Core; + +/// +/// Helper class for deserializing <c>JsonElement</c> objects. This handles +/// edge-cases around nullability and reference/value types. +/// +sealed class WrappedJsonSerializer +{ + public static T GetNotNullClass(JsonElement element, string name) + where T : class + { + T deserialized; + try + { + deserialized = + JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new OrbInvalidDataException($"'{name}' cannot be null"); + } + catch (JsonException e) + { + throw new OrbInvalidDataException($"'{name}' must be of type {typeof(T).FullName}", e); + } + return deserialized; + } + + public static T GetNotNullStruct(JsonElement element, string name) + where T : struct + { + T deserialized; + try + { + deserialized = + JsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new OrbInvalidDataException($"'{name}' cannot be null"); + } + catch (JsonException e) + { + throw new OrbInvalidDataException($"'{name}' must be of type {typeof(T).FullName}", e); + } + return deserialized; + } + + public static T? GetNullableClass(JsonElement element, string name) + where T : class + { + T? deserialized; + try + { + deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + catch (JsonException e) + { + throw new OrbInvalidDataException($"'{name}' must be of type {typeof(T).FullName}", e); + } + return deserialized; + } + + public static T? GetNullableStruct(JsonElement element, string name) + where T : struct + { + T? deserialized; + try + { + deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + } + catch (JsonException e) + { + throw new OrbInvalidDataException($"'{name}' must be of type {typeof(T).FullName}", e); + } + return deserialized; + } +} diff --git a/src/Orb/Core/WrappedMultipartJsonSerializer.cs b/src/Orb/Core/WrappedMultipartJsonSerializer.cs new file mode 100644 index 000000000..63ea77efd --- /dev/null +++ b/src/Orb/Core/WrappedMultipartJsonSerializer.cs @@ -0,0 +1,81 @@ +using System.Text.Json; +using Orb.Exceptions; + +namespace Orb.Core; + +/// +/// Helper class for deserializing <c>MultipartJsonElement</c> objects. +/// This handles edge-cases around nullability and reference/value types. +/// +sealed class WrappedMultipartJsonSerializer +{ + public static T GetNotNullClass(MultipartJsonElement element, string name) + where T : class + { + T deserialized; + try + { + deserialized = + MultipartJsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new OrbInvalidDataException($"'{name}' cannot be null"); + } + catch (JsonException e) + { + throw new OrbInvalidDataException($"'{name}' must be of type {typeof(T).FullName}", e); + } + return deserialized; + } + + public static T GetNotNullStruct(MultipartJsonElement element, string name) + where T : struct + { + T deserialized; + try + { + deserialized = + MultipartJsonSerializer.Deserialize(element, ModelBase.SerializerOptions) + ?? throw new OrbInvalidDataException($"'{name}' cannot be null"); + } + catch (JsonException e) + { + throw new OrbInvalidDataException($"'{name}' must be of type {typeof(T).FullName}", e); + } + return deserialized; + } + + public static T? GetNullableClass(MultipartJsonElement element, string name) + where T : class + { + T? deserialized; + try + { + deserialized = MultipartJsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + catch (JsonException e) + { + throw new OrbInvalidDataException($"'{name}' must be of type {typeof(T).FullName}", e); + } + return deserialized; + } + + public static T? GetNullableStruct(MultipartJsonElement element, string name) + where T : struct + { + T? deserialized; + try + { + deserialized = MultipartJsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + } + catch (JsonException e) + { + throw new OrbInvalidDataException($"'{name}' must be of type {typeof(T).FullName}", e); + } + return deserialized; + } +} 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..24cacc470 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) { @@ -251,7 +254,7 @@ public Adjustment(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -274,7 +277,7 @@ public bool TryPickPlanPhaseUsageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -297,7 +300,7 @@ public bool TryPickPlanPhaseAmountDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -320,7 +323,7 @@ public bool TryPickPlanPhasePercentageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -341,7 +344,7 @@ public bool TryPickPlanPhaseMinimum([NotNullWhen(true)] out PlanPhaseMinimumAdju /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -361,7 +364,7 @@ public bool TryPickPlanPhaseMaximum([NotNullWhen(true)] out PlanPhaseMaximumAdju /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -372,11 +375,11 @@ public bool TryPickPlanPhaseMaximum([NotNullWhen(true)] out PlanPhaseMaximumAdju /// /// /// instance.Switch( - /// (PlanPhaseUsageDiscountAdjustment value) => {...}, - /// (PlanPhaseAmountDiscountAdjustment value) => {...}, - /// (PlanPhasePercentageDiscountAdjustment value) => {...}, - /// (PlanPhaseMinimumAdjustment value) => {...}, - /// (PlanPhaseMaximumAdjustment value) => {...} + /// (PlanPhaseUsageDiscountAdjustment value) => {...}, + /// (PlanPhaseAmountDiscountAdjustment value) => {...}, + /// (PlanPhasePercentageDiscountAdjustment value) => {...}, + /// (PlanPhaseMinimumAdjustment value) => {...}, + /// (PlanPhaseMaximumAdjustment value) => {...} /// ); /// /// @@ -415,7 +418,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -426,11 +429,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (PlanPhaseUsageDiscountAdjustment value) => {...}, - /// (PlanPhaseAmountDiscountAdjustment value) => {...}, - /// (PlanPhasePercentageDiscountAdjustment value) => {...}, - /// (PlanPhaseMinimumAdjustment value) => {...}, - /// (PlanPhaseMaximumAdjustment value) => {...} + /// (PlanPhaseUsageDiscountAdjustment value) => {...}, + /// (PlanPhaseAmountDiscountAdjustment value) => {...}, + /// (PlanPhasePercentageDiscountAdjustment value) => {...}, + /// (PlanPhaseMinimumAdjustment value) => {...}, + /// (PlanPhaseMaximumAdjustment value) => {...} /// ); /// /// @@ -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 @@ -537,12 +556,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -560,12 +577,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -583,12 +598,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -605,12 +618,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -627,12 +638,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } 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..be41f69c1 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, @@ -103,29 +110,63 @@ IReadOnlyDictionary rawBodyData AlertCreateForCustomerParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static AlertCreateForCustomerParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + customerID ); } + 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 +195,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..771c1249c 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, @@ -105,29 +112,68 @@ IReadOnlyDictionary rawBodyData AlertCreateForExternalCustomerParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static AlertCreateForExternalCustomerParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + externalCustomerID ); } + 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 +202,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..e5d21e57b 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, @@ -110,29 +150,63 @@ IReadOnlyDictionary rawBodyData AlertCreateForSubscriptionParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static AlertCreateForSubscriptionParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + subscriptionID ); } + 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 +235,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..278cf6581 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, @@ -51,24 +58,61 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] AlertDisableParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string alertConfigurationID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.AlertConfigurationID = alertConfigurationID; } #pragma warning restore CS8618 - /// + /// public static AlertDisableParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string alertConfigurationID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + alertConfigurationID + ); + } + + 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) @@ -90,4 +134,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Alerts/AlertEnableParams.cs b/src/Orb/Models/Alerts/AlertEnableParams.cs index 530e5531b..9012a6834 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, @@ -51,24 +58,61 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] AlertEnableParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string alertConfigurationID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.AlertConfigurationID = alertConfigurationID; } #pragma warning restore CS8618 - /// + /// public static AlertEnableParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string alertConfigurationID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + alertConfigurationID + ); + } + + 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) @@ -90,4 +134,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/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..3e2cc2527 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, @@ -162,7 +169,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static AlertListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -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..7df8aecc9 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, @@ -36,24 +43,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] AlertRetrieveParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string alertID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.AlertID = alertID; } #pragma warning restore CS8618 - /// + /// public static AlertRetrieveParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string alertID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + alertID + ); + } + + 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) @@ -74,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/Alerts/AlertUpdateParams.cs b/src/Orb/Models/Alerts/AlertUpdateParams.cs index 4ef7d2ad1..874237651 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, @@ -68,27 +75,66 @@ IReadOnlyDictionary rawBodyData AlertUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string alertConfigurationID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.AlertConfigurationID = alertConfigurationID; } #pragma warning restore CS8618 - /// + /// public static AlertUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string alertConfigurationID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + alertConfigurationID + ); + } + + 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) @@ -119,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/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..6477aec2a 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, @@ -201,27 +208,61 @@ IReadOnlyDictionary rawBodyData BetaCreatePlanVersionParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string planID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.PlanID = planID; } #pragma warning restore CS8618 - /// + /// public static BetaCreatePlanVersionParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string planID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + planID + ); + } + + 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) @@ -252,6 +293,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 +306,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 +338,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 +364,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; @@ -417,7 +466,7 @@ public Adjustment(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -438,7 +487,7 @@ public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDi /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -459,7 +508,7 @@ public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -480,7 +529,7 @@ public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -501,7 +550,7 @@ public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -521,7 +570,7 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -532,11 +581,11 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// @@ -575,7 +624,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -586,11 +635,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// @@ -614,21 +663,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 +698,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 +709,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 @@ -700,12 +759,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -722,12 +779,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -744,12 +799,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -763,12 +816,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -782,12 +833,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -796,14 +845,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 +876,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 +907,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 +921,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 +962,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 +987,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 +1107,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 +1147,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 +1187,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 +1227,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 +1267,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 +1307,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 +1347,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 +1387,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 +1427,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,1012 +1467,984 @@ 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.CumulativeGroupedAllocation` + /// // `value` is of type `CumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out global::Orb.Models.Beta.CumulativeGroupedAllocation? value + [NotNullWhen(true)] out CumulativeGroupedAllocation? value ) { - value = this.Value as global::Orb.Models.Beta.CumulativeGroupedAllocation; + value = this.Value as CumulativeGroupedAllocation; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// - /// Consider using or if you need to handle every variant. + /// 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` + /// if (instance.TryPickMinimumComposite(out var value)) { + /// // `value` is of type `MinimumComposite` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickMinimum([NotNullWhen(true)] out global::Orb.Models.Beta.Minimum? value) + public bool TryPickMinimumComposite([NotNullWhen(true)] out MinimumComposite? value) { - value = this.Value as global::Orb.Models.Beta.Minimum; + 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.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. + /// 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. + /// 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; } /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2386,177 +2455,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); - break; - case NewPlanMinimumCompositePrice value: - newPlanMinimumComposite(value); + case MinimumComposite value: + minimumComposite(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" + ); } } @@ -2564,7 +2630,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2575,256 +2641,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 +2839,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 +2889,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,18 +2959,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2941,18 +2976,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2963,18 +2993,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2985,19 +3010,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3008,18 +3030,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3030,18 +3047,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3052,18 +3064,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3074,18 +3084,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3096,18 +3101,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3118,18 +3121,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3140,19 +3138,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3163,19 +3158,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3186,18 +3178,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3208,18 +3198,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3230,19 +3218,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3253,18 +3238,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3275,18 +3258,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3297,18 +3278,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3319,19 +3298,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3342,19 +3318,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3365,19 +3338,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3388,19 +3358,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3411,18 +3378,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3433,19 +3398,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3456,19 +3418,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3479,19 +3438,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3502,19 +3458,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3525,41 +3478,16 @@ 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 ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3570,18 +3498,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3592,18 +3518,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3614,19 +3535,13 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3635,14 +3550,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 +3565,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 +3643,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 +3715,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 +3809,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +3860,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 +3883,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 + /// 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.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)); - } -} - -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 - /// - 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.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, + public LicenseAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => + LicenseAllocation.FromRawUnchecked(rawData); } -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 - ); - } -} - -[JsonConverter(typeof(global::Orb.Models.Beta.ConversionRateConfigConverter))] +[JsonConverter(typeof(ConversionRateConfigConverter))] public record class ConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4351,7 +4109,7 @@ public ConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4372,7 +4130,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4392,7 +4150,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4403,8 +4161,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4433,7 +4191,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4444,8 +4202,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4465,13 +4223,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 +4250,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 +4261,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 @@ -4540,12 +4308,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4562,12 +4328,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4576,14 +4340,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 +4355,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 +4384,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 +4434,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 +4505,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 +4601,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +4654,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 +4675,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 +4734,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 +4744,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 +4764,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 +4779,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)); - } - } - - /// - 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.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 +4859,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 +4885,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public TieredConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5186,7 +4894,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public TieredConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5195,7 +4903,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public TieredConversionRateConfig(JsonElement element) { this._element = element; } @@ -5204,7 +4912,7 @@ public TieredWithProrationConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5225,7 +4933,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5245,7 +4953,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -5256,8 +4964,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5277,7 +4985,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" ); } } @@ -5286,7 +4994,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -5297,8 +5005,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5313,16 +5021,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 +5049,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 +5066,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 @@ -5395,12 +5113,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5417,12 +5133,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5431,14 +5145,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 +5160,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 +5202,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 +5310,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 +5406,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +5457,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 +5480,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 +5539,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 +5549,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 +5569,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 +5584,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 +5664,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 +5690,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public BulkConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5990,7 +5699,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public BulkConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5999,7 +5708,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public BulkConversionRateConfig(JsonElement element) { this._element = element; } @@ -6008,7 +5717,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6029,7 +5738,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6049,7 +5758,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -6060,8 +5769,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6081,7 +5790,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" ); } } @@ -6090,7 +5799,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -6101,8 +5810,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6117,16 +5826,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 +5854,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 +5871,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 @@ -6199,12 +5918,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6221,12 +5938,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6235,16 +5950,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 +5965,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 +6009,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 +6117,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 +6213,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +6264,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 +6292,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 +6424,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 +6601,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 +6611,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 +6631,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 +6646,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 +6733,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 +6759,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public BulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6796,7 +6768,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public BulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6805,7 +6777,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public BulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -6814,7 +6786,7 @@ public CumulativeGroupedAllocationConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6835,7 +6807,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6855,7 +6827,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -6866,8 +6838,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6887,7 +6859,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" ); } } @@ -6896,7 +6868,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -6907,8 +6879,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6923,16 +6895,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 +6923,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 +6940,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 @@ -7005,12 +6988,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7027,12 +7008,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7041,16 +7020,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 +7035,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 +7065,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 +7113,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 +7185,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 +7281,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +7334,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 +7355,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 +7414,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 +7424,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 +7444,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 +7459,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 +7567,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public PackageConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7569,7 +7576,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public PackageConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7578,7 +7585,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public PackageConversionRateConfig(JsonElement element) { this._element = element; } @@ -7587,7 +7594,7 @@ public MinimumConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7608,7 +7615,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7628,7 +7635,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -7639,8 +7646,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7660,7 +7667,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" ); } } @@ -7669,7 +7676,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -7680,8 +7687,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7696,16 +7703,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 +7731,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 +7748,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 @@ -7775,12 +7795,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7797,12 +7815,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7811,14 +7827,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 +7842,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 +7872,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 +7992,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 +8088,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +8141,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 +8162,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 +8221,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 +8231,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 +8251,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 +8266,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 +8372,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public MatrixConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8317,7 +8381,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public MatrixConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8326,7 +8390,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public MatrixConversionRateConfig(JsonElement element) { this._element = element; } @@ -8335,7 +8399,7 @@ public PercentConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8356,7 +8420,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8376,7 +8440,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -8387,8 +8451,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8408,7 +8472,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" ); } } @@ -8417,7 +8481,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -8428,8 +8492,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8444,16 +8508,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 +8536,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 +8553,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 @@ -8524,12 +8600,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8546,12 +8620,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8560,14 +8632,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 +8647,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 +8727,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 +8801,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 +8897,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +8949,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 +8976,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 +9016,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 +9038,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 +9048,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 +9068,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 +9083,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 +9368,7 @@ public JsonElement Json } } - public EventOutputConversionRateConfig( + public ThresholdTotalAmountConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9102,7 +9377,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig( + public ThresholdTotalAmountConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9111,7 +9386,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig(JsonElement element) + public ThresholdTotalAmountConversionRateConfig(JsonElement element) { this._element = element; } @@ -9120,7 +9395,7 @@ public EventOutputConversionRateConfig(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9141,7 +9416,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9161,7 +9436,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -9172,8 +9447,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9193,7 +9468,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" ); } } @@ -9202,7 +9477,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -9213,8 +9488,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9229,16 +9504,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 +9532,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 +9549,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 @@ -9309,12 +9597,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9331,12 +9617,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9345,14 +9629,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,435 +9644,776 @@ 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. + /// 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. + /// 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; } /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -9799,43 +10424,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" ); } } @@ -9844,7 +10454,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -9855,48 +10465,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 +10509,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,144 +10526,94 @@ 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 ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } return new(element); } - case "usage_discount": + case "tiered": { 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) + catch (JsonException) { // ignore } 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 ReplaceAdjustmentAdjustment(element); + return new TieredPackageConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplaceAdjustmentAdjustment value, + TieredPackageConversionRateConfig value, JsonSerializerOptions options ) { @@ -10081,2929 +10621,2115 @@ 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); } - } - - /// - public override void Validate() - { - _ = this.ReplacesPriceID; - this.AllocationPrice?.Validate(); - _ = this.PlanPhaseOrder; - this.Price?.Validate(); + init { this._rawData.Set("model_type", value); } } - public ReplacePrice() { } - - public ReplacePrice(ReplacePrice replacePrice) - : base(replacePrice) { } - - public ReplacePrice(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] - ReplacePrice(FrozenDictionary 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 restore CS8618 - /// - public static ReplacePrice 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 ReplacePrice(string replacesPriceID) - : 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.ReplacesPriceID = replacesPriceID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", 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; - public JsonElement Json + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" ); } + init { this._rawData.Set("billing_cycle_configuration", value); } } - public string ItemID + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate { 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.GetNullableStruct("conversion_rate"); } + init { this._rawData.Set("conversion_rate", value); } } - public string Name + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public TieredWithMinimumConversionRateConfig? ConversionRateConfig { 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( + "conversion_rate_config" ); } + init { this._rawData.Set("conversion_rate_config", value); } } - public string? BillableMetricID + /// + /// 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.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("currency"); } + init { this._rawData.Set("currency", value); } } - public bool? BilledInAdvance + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { 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.GetNullableClass( + "dimensional_price_configuration" ); } + init { this._rawData.Set("dimensional_price_configuration", value); } } - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + /// An alias for the price. + /// + public string? ExternalPriceID { 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("external_price_id"); } + init { this._rawData.Set("external_price_id", value); } } - public double? ConversionRate + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity { 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.GetNullableStruct("fixed_price_quantity"); } + init { this._rawData.Set("fixed_price_quantity", value); } } - public string? Currency + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey { 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("invoice_grouping_key"); } + init { this._rawData.Set("invoice_grouping_key", value); } } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + /// Within each 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.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( + "invoicing_cycle_configuration" ); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - public string? ExternalPriceID + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { get { - return Match( - newPlanUnit: (x) => x.ExternalPriceID, - newPlanTiered: (x) => x.ExternalPriceID, - newPlanBulk: (x) => x.ExternalPriceID, - bulkWithFilters: (x) => x.ExternalPriceID, - newPlanPackage: (x) => x.ExternalPriceID, - newPlanMatrix: (x) => x.ExternalPriceID, - newPlanThresholdTotalAmount: (x) => x.ExternalPriceID, - newPlanTieredPackage: (x) => x.ExternalPriceID, - newPlanTieredWithMinimum: (x) => x.ExternalPriceID, - newPlanGroupedTiered: (x) => x.ExternalPriceID, - newPlanTieredPackageWithMinimum: (x) => x.ExternalPriceID, - newPlanPackageWithAllocation: (x) => x.ExternalPriceID, - newPlanUnitWithPercent: (x) => x.ExternalPriceID, - newPlanMatrixWithAllocation: (x) => x.ExternalPriceID, - tieredWithProration: (x) => x.ExternalPriceID, - newPlanUnitWithProration: (x) => x.ExternalPriceID, - newPlanGroupedAllocation: (x) => x.ExternalPriceID, - newPlanBulkWithProration: (x) => x.ExternalPriceID, - newPlanGroupedWithProratedMinimum: (x) => x.ExternalPriceID, - newPlanGroupedWithMeteredMinimum: (x) => x.ExternalPriceID, - groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, - newPlanMatrixWithDisplayName: (x) => x.ExternalPriceID, - newPlanGroupedTieredPackage: (x) => x.ExternalPriceID, - newPlanMaxGroupTieredPackage: (x) => x.ExternalPriceID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, - newPlanCumulativeGroupedBulk: (x) => x.ExternalPriceID, - cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, - newPlanMinimumComposite: (x) => x.ExternalPriceID, - percent: (x) => x.ExternalPriceID, - eventOutput: (x) => x.ExternalPriceID - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); } + init { this._rawData.Set("license_type_id", value); } } - public double? FixedPriceQuantity + /// + /// User-specified key/value pairs for the resource. Individual keys can be 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.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>("metadata"); } - } - - public string? InvoiceGroupingKey - { - get + init { - 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 + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) ); } } - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + /// + /// 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.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 - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); } + init { this._rawData.Set("reference_id", value); } } - public string? ReferenceID + /// + public override void Validate() { - get + this.Cadence.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) { - 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 - ); + 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 ReplacePricePrice(NewPlanUnitPrice value, JsonElement? element = null) + public TieredWithMinimum() { - this.Value = value; - this._element = element; + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); } - public ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimum(TieredWithMinimum tieredWithMinimum) + : base(tieredWithMinimum) { } +#pragma warning restore CS8618 + + 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 ) + : base(tieredWithMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public TieredWithMinimumLicenseAllocation(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public ReplacePricePrice(NewPlanPackageWithAllocationPrice 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(NewPlanUnitWithPercentPrice value, JsonElement? element = null) + /// + public static TieredWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public ReplacePricePrice(NewPlanMatrixWithAllocationPrice 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( - ReplacePricePriceTieredWithProration 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(NewPlanUnitWithProrationPrice 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(NewPlanGroupedAllocationPrice 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(NewPlanBulkWithProrationPrice 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( - NewPlanGroupedWithProratedMinimumPrice 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( - NewPlanGroupedWithMeteredMinimumPrice value, - JsonElement? element = null + /// + public static TieredWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - public ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null - ) + [SetsRequiredMembers] + public TieredWithMinimumConfig(IReadOnlyList tiers) + : this() { - this.Value = value; - this._element = element; + this.Tiers = tiers; } +} - public ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice 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(NewPlanGroupedTieredPackagePrice 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(NewPlanMaxGroupTieredPackagePrice 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( - NewPlanScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.MinimumAmount; + _ = this.TierLowerBound; + _ = this.UnitAmount; } - public ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice 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(NewPlanCumulativeGroupedBulkPrice 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( - ReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null + /// + public static TieredWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public ReplacePricePrice(ReplacePricePriceMinimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } +class TieredWithMinimumConfigTierFromRaw : IFromRawJson +{ + /// + public TieredWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithMinimumConfigTier.FromRawUnchecked(rawData); +} - public ReplacePricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) +[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(ReplacePricePricePercent value, JsonElement? element = null) + 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. + /// 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. + /// 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. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. /// - /// Consider using or if you need to handle every variant. + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// /// /// /// - /// if (instance.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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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() + { + 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 ) { - value = this.Value as NewPlanMinimumCompositePrice; - 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), + }; } - /// - /// Returns true and sets the 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 override void Write( + Utf8JsonWriter writer, + GroupedTieredCadence value, + JsonSerializerOptions options + ) { - value = this.Value as ReplacePricePricePercent; - return value != null; + 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 +{ /// - /// Returns true and sets the 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); - /// } - /// - /// + /// The billable metric property used to group before tiering /// - public bool TryPickEventOutput([NotNullWhen(true)] out ReplacePricePriceEventOutput? value) + public required string GroupingKey { - value = this.Value as ReplacePricePriceEventOutput; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } } /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the 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) => {...} - /// ); - /// - /// + /// Apply tiered pricing to each segment generated after grouping with the provided key /// - 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 - ) + public required IReadOnlyList Tiers { - switch (this.Value) + get { - case NewPlanUnitPrice value: - newPlanUnit(value); - break; - case NewPlanTieredPrice value: - newPlanTiered(value); - break; - case NewPlanBulkPrice value: - newPlanBulk(value); - break; - case ReplacePricePriceBulkWithFilters value: - bulkWithFilters(value); - break; - case NewPlanPackagePrice value: - newPlanPackage(value); - break; - case NewPlanMatrixPrice value: - newPlanMatrix(value); - break; - case NewPlanThresholdTotalAmountPrice value: - newPlanThresholdTotalAmount(value); - break; - case NewPlanTieredPackagePrice value: - newPlanTieredPackage(value); - break; - case NewPlanTieredWithMinimumPrice value: - newPlanTieredWithMinimum(value); - break; - case NewPlanGroupedTieredPrice value: - newPlanGroupedTiered(value); - break; - case NewPlanTieredPackageWithMinimumPrice value: - newPlanTieredPackageWithMinimum(value); - break; - case NewPlanPackageWithAllocationPrice value: - newPlanPackageWithAllocation(value); - break; - case NewPlanUnitWithPercentPrice value: - newPlanUnitWithPercent(value); - break; - case NewPlanMatrixWithAllocationPrice value: - newPlanMatrixWithAllocation(value); - break; - case ReplacePricePriceTieredWithProration value: - tieredWithProration(value); - break; - case NewPlanUnitWithProrationPrice value: - newPlanUnitWithProration(value); - break; - case NewPlanGroupedAllocationPrice value: - newPlanGroupedAllocation(value); - break; - case NewPlanBulkWithProrationPrice value: - newPlanBulkWithProration(value); - break; - case NewPlanGroupedWithProratedMinimumPrice value: - newPlanGroupedWithProratedMinimum(value); - break; - case NewPlanGroupedWithMeteredMinimumPrice value: - newPlanGroupedWithMeteredMinimum(value); - break; - case ReplacePricePriceGroupedWithMinMaxThresholds value: - groupedWithMinMaxThresholds(value); - break; - case NewPlanMatrixWithDisplayNamePrice value: - newPlanMatrixWithDisplayName(value); - break; - case NewPlanGroupedTieredPackagePrice value: - newPlanGroupedTieredPackage(value); - break; - case NewPlanMaxGroupTieredPackagePrice value: - newPlanMaxGroupTieredPackage(value); - break; - case NewPlanScalableMatrixWithUnitPricingPrice value: - newPlanScalableMatrixWithUnitPricing(value); - break; - case NewPlanScalableMatrixWithTieredPricingPrice value: - newPlanScalableMatrixWithTieredPricing(value); - break; - case NewPlanCumulativeGroupedBulkPrice value: - newPlanCumulativeGroupedBulk(value); - break; - case ReplacePricePriceCumulativeGroupedAllocation value: - cumulativeGroupedAllocation(value); - break; - case ReplacePricePriceMinimum value: - minimum(value); - break; - case NewPlanMinimumCompositePrice value: - newPlanMinimumComposite(value); - break; - case ReplacePricePricePercent value: - percent(value); - break; - case ReplacePricePriceEventOutput value: - eventOutput(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("tiers"); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, - /// (ReplacePricePriceBulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (ReplacePricePriceTieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, - /// (NewPlanGroupedTieredPackagePrice value) => {...}, - /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, - /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (ReplacePricePriceMinimum value) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, - /// (ReplacePricePricePercent value) => {...}, - /// (ReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func newPlanUnit, - System::Func newPlanTiered, - System::Func newPlanBulk, - System::Func bulkWithFilters, - System::Func newPlanPackage, - System::Func newPlanMatrix, - System::Func newPlanThresholdTotalAmount, - System::Func newPlanTieredPackage, - System::Func newPlanTieredWithMinimum, - System::Func newPlanGroupedTiered, - System::Func newPlanTieredPackageWithMinimum, - System::Func newPlanPackageWithAllocation, - System::Func newPlanUnitWithPercent, - System::Func newPlanMatrixWithAllocation, - System::Func tieredWithProration, - System::Func newPlanUnitWithProration, - System::Func newPlanGroupedAllocation, - System::Func newPlanBulkWithProration, - System::Func newPlanGroupedWithProratedMinimum, - System::Func newPlanGroupedWithMeteredMinimum, - System::Func groupedWithMinMaxThresholds, - System::Func newPlanMatrixWithDisplayName, - System::Func newPlanGroupedTieredPackage, - System::Func newPlanMaxGroupTieredPackage, - System::Func< - NewPlanScalableMatrixWithUnitPricingPrice, - T - > newPlanScalableMatrixWithUnitPricing, - System::Func< - NewPlanScalableMatrixWithTieredPricingPrice, - T - > newPlanScalableMatrixWithTieredPricing, - System::Func newPlanCumulativeGroupedBulk, - System::Func cumulativeGroupedAllocation, - System::Func minimum, - System::Func newPlanMinimumComposite, - System::Func percent, - System::Func eventOutput - ) + /// + public override void Validate() { - return this.Value switch + _ = this.GroupingKey; + foreach (var item in this.Tiers) { - NewPlanUnitPrice value => newPlanUnit(value), - NewPlanTieredPrice value => newPlanTiered(value), - NewPlanBulkPrice value => newPlanBulk(value), - ReplacePricePriceBulkWithFilters value => bulkWithFilters(value), - NewPlanPackagePrice value => newPlanPackage(value), - NewPlanMatrixPrice value => newPlanMatrix(value), - NewPlanThresholdTotalAmountPrice value => newPlanThresholdTotalAmount(value), - NewPlanTieredPackagePrice value => newPlanTieredPackage(value), - NewPlanTieredWithMinimumPrice value => newPlanTieredWithMinimum(value), - NewPlanGroupedTieredPrice value => newPlanGroupedTiered(value), - NewPlanTieredPackageWithMinimumPrice value => newPlanTieredPackageWithMinimum(value), - NewPlanPackageWithAllocationPrice value => newPlanPackageWithAllocation(value), - NewPlanUnitWithPercentPrice value => newPlanUnitWithPercent(value), - NewPlanMatrixWithAllocationPrice value => newPlanMatrixWithAllocation(value), - ReplacePricePriceTieredWithProration value => tieredWithProration(value), - NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), - NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), - NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), - NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( - value - ), - NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), - ReplacePricePriceGroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds( - value - ), - NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), - NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), - NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), - NewPlanScalableMatrixWithUnitPricingPrice value => newPlanScalableMatrixWithUnitPricing( - value - ), - NewPlanScalableMatrixWithTieredPricingPrice value => - newPlanScalableMatrixWithTieredPricing(value), - NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), - ReplacePricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation( - value - ), - ReplacePricePriceMinimum value => minimum(value), - NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), - ReplacePricePricePercent value => percent(value), - ReplacePricePriceEventOutput value => eventOutput(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ), - }; + item.Validate(); + } } - 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 GroupedTieredConfig() { } - public static implicit operator ReplacePricePrice(NewPlanMatrixPrice value) => new(value); - - public static implicit operator ReplacePricePrice(NewPlanThresholdTotalAmountPrice value) => - new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredConfig(GroupedTieredConfig groupedTieredConfig) + : base(groupedTieredConfig) { } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice(NewPlanTieredPackagePrice value) => - new(value); + public GroupedTieredConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } - public static implicit operator ReplacePricePrice(NewPlanTieredWithMinimumPrice value) => - new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPrice value) => - new(value); + /// + public static GroupedTieredConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator ReplacePricePrice(NewPlanTieredPackageWithMinimumPrice value) => - new(value); +class GroupedTieredConfigFromRaw : IFromRawJson +{ + /// + public GroupedTieredConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + GroupedTieredConfig.FromRawUnchecked(rawData); +} - public static implicit operator ReplacePricePrice(NewPlanPackageWithAllocationPrice value) => - new(value); +/// +/// 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); } + } - public static implicit operator ReplacePricePrice(NewPlanUnitWithPercentPrice value) => - new(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 static implicit operator ReplacePricePrice(NewPlanMatrixWithAllocationPrice value) => - new(value); + /// + public override void Validate() + { + _ = this.TierLowerBound; + _ = this.UnitAmount; + } - public static implicit operator ReplacePricePrice(ReplacePricePriceTieredWithProration value) => - new(value); + public GroupedTieredConfigTier() { } - public static implicit operator ReplacePricePrice(NewPlanUnitWithProrationPrice value) => - new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredConfigTier(GroupedTieredConfigTier groupedTieredConfigTier) + : base(groupedTieredConfigTier) { } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice(NewPlanGroupedAllocationPrice value) => - new(value); + public GroupedTieredConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } - public static implicit operator ReplacePricePrice(NewPlanBulkWithProrationPrice value) => - new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); + /// + public static GroupedTieredConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); +class GroupedTieredConfigTierFromRaw : IFromRawJson +{ + /// + public GroupedTieredConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredConfigTier.FromRawUnchecked(rawData); +} - public static implicit operator ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); +[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); } + } - public static implicit operator ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value) => - new(value); + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } - public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPackagePrice value) => - new(value); + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } - public static implicit operator ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value) => - new(value); + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } - public static implicit operator ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); + public GroupedTieredLicenseAllocation() { } - public static implicit operator ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredLicenseAllocation( + GroupedTieredLicenseAllocation groupedTieredLicenseAllocation + ) + : base(groupedTieredLicenseAllocation) { } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value) => - new(value); + public GroupedTieredLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } - public static implicit operator ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice(ReplacePricePriceMinimum value) => new(value); + /// + public static GroupedTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator ReplacePricePrice(NewPlanMinimumCompositePrice value) => - new(value); +class GroupedTieredLicenseAllocationFromRaw : IFromRawJson +{ + /// + public GroupedTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredLicenseAllocation.FromRawUnchecked(rawData); +} - public static implicit operator ReplacePricePrice(ReplacePricePricePercent value) => new(value); +[JsonConverter(typeof(GroupedTieredConversionRateConfigConverter))] +public record class GroupedTieredConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; - public static implicit operator ReplacePricePrice(ReplacePricePriceEventOutput value) => - new(value); + JsonElement? _element = null; - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances 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 JsonElement Json { - if (this.Value == null) + get { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions ); } - this.Switch( - (newPlanUnit) => newPlanUnit.Validate(), - (newPlanTiered) => newPlanTiered.Validate(), - (newPlanBulk) => newPlanBulk.Validate(), - (bulkWithFilters) => bulkWithFilters.Validate(), - (newPlanPackage) => newPlanPackage.Validate(), - (newPlanMatrix) => newPlanMatrix.Validate(), - (newPlanThresholdTotalAmount) => newPlanThresholdTotalAmount.Validate(), - (newPlanTieredPackage) => newPlanTieredPackage.Validate(), - (newPlanTieredWithMinimum) => newPlanTieredWithMinimum.Validate(), - (newPlanGroupedTiered) => newPlanGroupedTiered.Validate(), - (newPlanTieredPackageWithMinimum) => newPlanTieredPackageWithMinimum.Validate(), - (newPlanPackageWithAllocation) => newPlanPackageWithAllocation.Validate(), - (newPlanUnitWithPercent) => newPlanUnitWithPercent.Validate(), - (newPlanMatrixWithAllocation) => newPlanMatrixWithAllocation.Validate(), - (tieredWithProration) => tieredWithProration.Validate(), - (newPlanUnitWithProration) => newPlanUnitWithProration.Validate(), - (newPlanGroupedAllocation) => newPlanGroupedAllocation.Validate(), - (newPlanBulkWithProration) => newPlanBulkWithProration.Validate(), - (newPlanGroupedWithProratedMinimum) => newPlanGroupedWithProratedMinimum.Validate(), - (newPlanGroupedWithMeteredMinimum) => newPlanGroupedWithMeteredMinimum.Validate(), - (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), - (newPlanMatrixWithDisplayName) => newPlanMatrixWithDisplayName.Validate(), - (newPlanGroupedTieredPackage) => newPlanGroupedTieredPackage.Validate(), - (newPlanMaxGroupTieredPackage) => newPlanMaxGroupTieredPackage.Validate(), - (newPlanScalableMatrixWithUnitPricing) => - newPlanScalableMatrixWithUnitPricing.Validate(), - (newPlanScalableMatrixWithTieredPricing) => - newPlanScalableMatrixWithTieredPricing.Validate(), - (newPlanCumulativeGroupedBulk) => newPlanCumulativeGroupedBulk.Validate(), - (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), - (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), - (percent) => percent.Validate(), - (eventOutput) => eventOutput.Validate() - ); } - public virtual bool Equals(ReplacePricePrice? other) + public GroupedTieredConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + this.Value = value; + this._element = element; } - public override int GetHashCode() + public GroupedTieredConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) { - return 0; + this.Value = value; + this._element = element; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class ReplacePricePriceConverter : JsonConverter -{ - public override ReplacePricePrice? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + public GroupedTieredConversionRateConfig(JsonElement element) { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try - { - modelType = element.GetProperty("model_type").GetString(); - } - catch - { - modelType = null; - } + this._element = element; + } - switch (modelType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `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 "tiered": - { - try - { - var deserialized = JsonSerializer.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 "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 - } + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.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" + ); + } + } - 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 - } + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::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" + ), + }; + } - 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 implicit operator GroupedTieredConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); - return new(element); - } - case "matrix": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public static implicit operator GroupedTieredConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(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 - } + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when 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()); + } - 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 - } + public virtual bool Equals(GroupedTieredConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); - 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 - } + public override int GetHashCode() + { + return 0; + } - 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 string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - 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 - } + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} - 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 - } +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; + } - return new(element); - } - case "unit_with_percent": + switch (conversionRateType) + { + case "unit": { 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) + catch (JsonException) { // ignore } return new(element); } - case "matrix_with_allocation": + case "tiered": { 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) + catch (JsonException) { // ignore } return new(element); } - case "tiered_with_proration": + 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 "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 override void Write( + Utf8JsonWriter writer, + GroupedTieredConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} - 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 - } +[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 "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 - } + /// + /// The id of the item the price will 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 "grouped_with_metered_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix_with_display_name": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_tiered_package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "max_group_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_unit_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_tiered_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_bulk": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum_composite": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "percent": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "event_output": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new ReplacePricePrice(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - ReplacePricePrice? value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value?.Json, options); - } -} - -[JsonConverter( - typeof(JsonModelConverter< - ReplacePricePriceBulkWithFilters, - ReplacePricePriceBulkWithFiltersFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFilters : JsonModel -{ /// - /// Configuration for bulk_with_filters pricing + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. /// - public required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig + public required IReadOnlyList LicenseAllocations { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); } - init { this._rawData.Set("bulk_with_filters_config", value); } - } - - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum Cadence - { - get + init { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("cadence", value); } } /// - /// The id of the item the price will be associated with. + /// The pricing model type /// - public required string ItemID + public JsonElement ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullStruct("model_type"); } - init { this._rawData.Set("item_id", 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 tiered_package_with_minimum pricing /// - public required string Name + public required TieredPackageWithMinimumConfig TieredPackageWithMinimumConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); + return this._rawData.GetNotNullClass( + "tiered_package_with_minimum_config" + ); } - init { this._rawData.Set("name", value); } + init { this._rawData.Set("tiered_package_with_minimum_config", value); } } /// @@ -13065,12 +12791,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig + public TieredPackageWithMinimumConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -13161,6 +12887,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -13199,19 +12938,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(); @@ -13223,37 +12966,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( - 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 ReplacePricePriceBulkWithFilters FromRawUnchecked( + /// + public static TieredPackageWithMinimum FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -13261,86 +13006,140 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson +class TieredPackageWithMinimumFromRaw : IFromRawJson { /// - public ReplacePricePriceBulkWithFilters FromRawUnchecked( + public TieredPackageWithMinimum FromRawUnchecked( IReadOnlyDictionary rawData - ) => 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< - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, - 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( - 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 ) { @@ -13349,16 +13148,14 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - FrozenDictionary rawData - ) + TieredPackageWithMinimumLicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + /// + public static TieredPackageWithMinimumLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -13366,85 +13163,93 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - : IFromRawJson +class TieredPackageWithMinimumLicenseAllocationFromRaw + : IFromRawJson { /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + public TieredPackageWithMinimumLicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); + ) => TieredPackageWithMinimumLicenseAllocation.FromRawUnchecked(rawData); } /// -/// Configuration for a single property filter +/// Configuration for tiered_package_with_minimum pricing /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, - 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( - 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + /// + public static TieredPackageWithMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -13452,48 +13257,51 @@ IReadOnlyDictionary rawData } } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw - : IFromRawJson +class TieredPackageWithMinimumConfigFromRaw : IFromRawJson { /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + public TieredPackageWithMinimumConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); + ) => TieredPackageWithMinimumConfig.FromRawUnchecked(rawData); } /// -/// Configuration for a single bulk pricing tier +/// Configuration for a single tier /// [JsonConverter( typeof(JsonModelConverter< - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, - 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); } } @@ -13501,381 +13309,64958 @@ public string? TierLowerBound /// public override void Validate() { - _ = this.UnitAmount; + _ = this.MinimumAmount; + _ = this.PerUnit; _ = this.TierLowerBound; } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } + public TieredPackageWithMinimumConfigTier() { } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - 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 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + public TieredPackageWithMinimumConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); + ) => TieredPackageWithMinimumConfigTier.FromRawUnchecked(rawData); } -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersCadenceConverter))] -public enum ReplacePricePriceBulkWithFiltersCadence +[JsonConverter(typeof(TieredPackageWithMinimumConversionRateConfigConverter))] +public record class TieredPackageWithMinimumConversionRateConfig : ModelBase { - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, + 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 ReplacePricePriceBulkWithFiltersCadenceConverter - : JsonConverter +sealed class TieredPackageWithMinimumConversionRateConfigConverter + : JsonConverter { - public override ReplacePricePriceBulkWithFiltersCadence Read( + public override TieredPackageWithMinimumConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { - return JsonSerializer.Deserialize(ref reader, options) switch + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try { - "annual" => ReplacePricePriceBulkWithFiltersCadence.Annual, - "semi_annual" => ReplacePricePriceBulkWithFiltersCadence.SemiAnnual, - "monthly" => ReplacePricePriceBulkWithFiltersCadence.Monthly, - "quarterly" => ReplacePricePriceBulkWithFiltersCadence.Quarterly, - "one_time" => ReplacePricePriceBulkWithFiltersCadence.OneTime, - "custom" => ReplacePricePriceBulkWithFiltersCadence.Custom, - _ => (ReplacePricePriceBulkWithFiltersCadence)(-1), - }; + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + } + catch + { + conversionRateType = null; + } + + switch (conversionRateType) + { + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + default: + { + return new TieredPackageWithMinimumConversionRateConfig(element); + } + } } public override void Write( Utf8JsonWriter writer, - ReplacePricePriceBulkWithFiltersCadence value, + TieredPackageWithMinimumConversionRateConfig 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 - ); + JsonSerializer.Serialize(writer, value.Json, options); } } -[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] -public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PackageWithAllocation : JsonModel { - public object? Value { get; } = null; + /// + /// 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); } + } - JsonElement? _element = null; + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } - public JsonElement Json + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions + 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); } } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID + { + get + { + 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_prorated_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_metered_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_min_max_thresholds": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "max_group_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "scalable_matrix_with_unit_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "scalable_matrix_with_tiered_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "cumulative_grouped_bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "cumulative_grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "minimum_composite": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "percent": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "event_output": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "usage_discount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "amount_discount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "maximum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_prorated_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_metered_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_min_max_thresholds": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "max_group_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "scalable_matrix_with_unit_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "scalable_matrix_with_tiered_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "cumulative_grouped_bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "cumulative_grouped_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "minimum_composite": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "percent": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "event_output": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public override int GetHashCode() - { - return 0; - } + return new(element); + } + case "cumulative_grouped_bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - switch (conversionRateType) - { - case "unit": + return new(element); + } + 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) + catch (JsonException) { // ignore } return new(element); } - case "tiered": + case "event_output": { 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) + catch (JsonException) { // ignore } @@ -13884,39 +78269,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 +78361,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 +78420,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 +78516,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +78567,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 +78591,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 +78633,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 +78695,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 +78724,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( FrozenDictionary rawData ) { @@ -14365,86 +78732,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 +78902,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( FrozenDictionary rawData ) { @@ -14461,27 +78910,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 +79013,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -14507,7 +79022,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -14516,7 +79031,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -14525,7 +79040,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement elem /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -14546,7 +79061,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -14566,7 +79081,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -14577,8 +79092,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14598,7 +79113,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" ); } } @@ -14607,7 +79122,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -14618,8 +79133,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14634,16 +79149,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 +79177,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 +79194,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 @@ -14714,12 +79242,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14736,12 +79262,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14750,14 +79274,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 +79291,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 +79351,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 +79425,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 +79521,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +79573,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 +79596,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 +79638,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 +79661,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 +79672,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 +79692,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 +79708,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 +79866,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -15265,8 +79874,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15274,20 +79883,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 +79911,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15313,7 +79920,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15322,7 +79929,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -15331,7 +79938,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElem /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -15352,7 +79959,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -15372,7 +79979,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -15383,8 +79990,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15404,7 +80011,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" ); } } @@ -15413,7 +80020,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -15424,8 +80031,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15440,16 +80047,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 +80075,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 +80092,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 @@ -15522,12 +80140,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -15544,12 +80160,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -15558,16 +80172,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 +80189,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 +80323,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 +80419,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +80471,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 +80494,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 +80538,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 +80561,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 +80572,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 +80592,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 +80608,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 +80699,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -16075,8 +80707,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16084,20 +80716,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 +80746,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16123,7 +80755,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16132,7 +80764,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -16141,7 +80773,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElem /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -16162,7 +80794,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -16182,7 +80814,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -16193,8 +80825,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16214,7 +80846,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" ); } } @@ -16223,7 +80855,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -16234,8 +80866,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16250,16 +80882,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 +80910,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 +80929,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 @@ -16332,12 +80977,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -16354,12 +80997,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -16368,7 +81009,7 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -16377,7 +81018,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -16386,51 +81027,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 +81162,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 +81258,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +81310,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 +81333,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 +81377,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 +81400,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 +81411,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 +81431,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 +81447,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 +81585,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16899,7 +81594,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16908,7 +81603,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -16917,7 +81612,7 @@ public ReplacePricePriceMinimumConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -16938,7 +81633,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -16958,7 +81653,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -16969,8 +81664,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16990,7 +81685,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" ); } } @@ -16999,7 +81694,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -17010,8 +81705,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17026,16 +81721,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 +81749,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 +81768,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 @@ -17106,12 +81816,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -17128,12 +81836,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -17142,14 +81848,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 +82094,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +82164,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -17452,8 +82174,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 +82304,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) { @@ -17667,7 +82395,7 @@ public ReplacePricePricePercentConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -17688,7 +82416,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -17708,7 +82436,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -17719,8 +82447,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17749,7 +82477,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -17760,8 +82488,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17810,10 +82538,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 +82549,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 @@ -17856,12 +82597,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -17878,12 +82617,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -18136,6 +82873,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +82948,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -18207,8 +82958,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 +83119,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 @@ -18455,7 +83212,7 @@ public ReplacePricePriceEventOutputConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -18476,7 +83233,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -18496,7 +83253,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -18507,8 +83264,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18537,7 +83294,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -18548,8 +83305,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18598,10 +83355,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 +83366,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 @@ -18644,12 +83414,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -18666,12 +83434,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Beta/BetaFetchPlanVersionParams.cs b/src/Orb/Models/Beta/BetaFetchPlanVersionParams.cs index 2ed83f89a..c4586dea3 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, @@ -40,24 +47,62 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] BetaFetchPlanVersionParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string planID, + string version ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.PlanID = planID; + this.Version = version; } #pragma warning restore CS8618 - /// + /// public static BetaFetchPlanVersionParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string planID, + string version ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + planID, + version + ); + } + + 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) @@ -79,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/Beta/BetaSetDefaultPlanVersionParams.cs b/src/Orb/Models/Beta/BetaSetDefaultPlanVersionParams.cs index afc5ef444..00548f5da 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, @@ -63,27 +70,61 @@ IReadOnlyDictionary rawBodyData BetaSetDefaultPlanVersionParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string planID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.PlanID = planID; } #pragma warning restore CS8618 - /// + /// public static BetaSetDefaultPlanVersionParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string planID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + planID + ); + } + + 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) @@ -114,4 +155,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..0352f9cdb 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, @@ -205,27 +210,61 @@ IReadOnlyDictionary rawBodyData ExternalPlanIDCreatePlanVersionParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string externalPlanID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ExternalPlanID = externalPlanID; } #pragma warning restore CS8618 - /// + /// public static ExternalPlanIDCreatePlanVersionParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string externalPlanID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + externalPlanID + ); + } + + 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) @@ -256,27 +295,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 +340,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 +359,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; @@ -431,7 +468,7 @@ public Adjustment(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -452,7 +489,7 @@ public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDi /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -473,7 +510,7 @@ public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -494,7 +531,7 @@ public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -515,7 +552,7 @@ public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -535,7 +572,7 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -546,11 +583,11 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// @@ -589,7 +626,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -600,11 +637,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// @@ -628,25 +665,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 +700,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 +711,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 @@ -718,12 +761,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -740,12 +781,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -762,12 +801,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -781,12 +818,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -800,12 +835,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -814,14 +847,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 +862,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 +878,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 +909,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 +923,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 +949,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 +989,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 +1109,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 +1149,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 +1189,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 +1229,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 +1269,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 +1309,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 +1349,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 +1389,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 +1429,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,1027 +1469,984 @@ 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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; } /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2429,177 +2457,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); - break; - case NewPlanMinimumCompositePrice value: - newPlanMinimumComposite(value); + case MinimumComposite value: + minimumComposite(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" + ); } } @@ -2607,7 +2632,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2618,266 +2643,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 +2841,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 +2891,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,18 +2961,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2994,18 +2978,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3016,18 +2995,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3038,19 +3012,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3061,18 +3032,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3083,18 +3049,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3105,18 +3066,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3127,18 +3086,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3149,18 +3103,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3171,18 +3123,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3193,19 +3140,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3216,19 +3160,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3239,18 +3180,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3261,18 +3200,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3283,19 +3220,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3306,18 +3240,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3328,18 +3260,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3350,18 +3280,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3372,19 +3300,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3395,19 +3320,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3418,19 +3340,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3441,19 +3360,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3464,18 +3380,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3486,19 +3400,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3509,19 +3420,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3532,19 +3440,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3555,19 +3460,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3578,64 +3480,36 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } return new(element); } - case "minimum": + 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 "minimum_composite": - { - 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) + catch (JsonException) { // ignore } @@ -3646,19 +3520,13 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3669,19 +3537,13 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3690,14 +3552,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 +3567,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 +3645,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 +3717,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 +3811,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +3862,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 +3885,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 - /// - 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() { } - - 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 + /// 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.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, + public LicenseAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => + LicenseAllocation.FromRawUnchecked(rawData); } -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 - ); - } -} - -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfigConverter))] +[JsonConverter(typeof(ConversionRateConfigConverter))] public record class ConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4410,7 +4111,7 @@ public ConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4431,7 +4132,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4451,7 +4152,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4462,8 +4163,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4492,7 +4193,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4503,8 +4204,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4524,13 +4225,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 +4252,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 +4263,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 @@ -4599,12 +4310,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4621,12 +4330,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4635,14 +4342,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 +4357,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 +4386,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 +4436,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 +4507,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 +4603,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +4656,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 +4677,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 +4736,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 +4746,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 +4766,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 +4781,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)); + 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.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 +4861,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 +4887,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public TieredConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5272,7 +4896,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public TieredConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5281,7 +4905,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public TieredConversionRateConfig(JsonElement element) { this._element = element; } @@ -5290,7 +4914,7 @@ public TieredWithProrationConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5311,7 +4935,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5331,7 +4955,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -5342,8 +4966,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5363,7 +4987,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" ); } } @@ -5372,7 +4996,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -5383,8 +5007,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5399,16 +5023,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 +5051,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 +5068,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 @@ -5481,12 +5115,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5503,12 +5135,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5517,16 +5147,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 +5162,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 +5204,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 +5312,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 +5408,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +5459,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 +5482,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 +5541,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 +5551,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 +5571,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 +5586,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 + /// 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.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 +5666,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 +5692,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public BulkConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6132,7 +5701,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public BulkConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6141,7 +5710,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public BulkConversionRateConfig(JsonElement element) { this._element = element; } @@ -6150,7 +5719,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6171,7 +5740,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6191,7 +5760,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -6202,8 +5771,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6223,7 +5792,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" ); } } @@ -6232,7 +5801,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -6243,8 +5812,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6259,16 +5828,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 +5856,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 +5873,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 @@ -6341,12 +5920,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6363,12 +5940,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6377,16 +5952,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 +5967,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 +6011,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 +6119,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 +6215,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +6266,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 +6294,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 +6426,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 +6603,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 +6613,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 +6633,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 +6648,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 +6735,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 +6761,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public BulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6992,7 +6770,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public BulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7001,7 +6779,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public BulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -7010,7 +6788,7 @@ public CumulativeGroupedAllocationConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7031,7 +6809,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7051,7 +6829,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -7062,8 +6840,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7083,7 +6861,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" ); } } @@ -7092,7 +6870,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -7103,8 +6881,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7119,16 +6897,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 +6925,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 +6942,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 @@ -7201,12 +6990,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7223,12 +7010,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7237,16 +7022,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 +7037,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 +7067,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 +7115,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 +7187,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 +7283,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +7336,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 +7357,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 +7416,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 +7426,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 +7446,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 +7461,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 +7569,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public PackageConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7768,7 +7578,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public PackageConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7777,7 +7587,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public PackageConversionRateConfig(JsonElement element) { this._element = element; } @@ -7786,7 +7596,7 @@ public MinimumConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7807,7 +7617,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7827,7 +7637,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -7838,8 +7648,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7859,7 +7669,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" ); } } @@ -7868,7 +7678,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -7879,8 +7689,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7895,16 +7705,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 +7733,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 +7750,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 @@ -7977,12 +7797,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7999,12 +7817,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8013,16 +7829,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 +7844,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 +7874,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 +7994,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 +8090,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +8143,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 +8164,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 +8223,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 +8233,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 +8253,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 +8268,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 +8374,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public MatrixConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8522,7 +8383,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public MatrixConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8531,7 +8392,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public MatrixConversionRateConfig(JsonElement element) { this._element = element; } @@ -8540,7 +8401,7 @@ public PercentConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8561,7 +8422,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8581,7 +8442,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -8592,8 +8453,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8613,7 +8474,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" ); } } @@ -8622,7 +8483,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -8633,8 +8494,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8649,16 +8510,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 +8538,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 +8555,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 @@ -8731,12 +8602,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8753,12 +8622,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8767,16 +8634,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 +8649,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 +8729,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 +8803,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 +8899,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +8951,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 +8978,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 +9018,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 +9040,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 +9050,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 +9070,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 +9085,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 +9370,7 @@ public JsonElement Json } } - public EventOutputConversionRateConfig( + public ThresholdTotalAmountConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9321,7 +9379,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig( + public ThresholdTotalAmountConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9330,7 +9388,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig(JsonElement element) + public ThresholdTotalAmountConversionRateConfig(JsonElement element) { this._element = element; } @@ -9339,7 +9397,7 @@ public EventOutputConversionRateConfig(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9360,7 +9418,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9380,7 +9438,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -9391,8 +9449,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9412,7 +9470,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" ); } } @@ -9421,7 +9479,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -9432,8 +9490,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9448,16 +9506,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 +9534,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 +9551,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 @@ -9530,12 +9599,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9552,12 +9619,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9566,16 +9631,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,463 +9646,776 @@ 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. + /// 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. + /// 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; } /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -10050,43 +10426,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" ); } } @@ -10095,7 +10456,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -10106,54 +10467,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 +10511,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,147 +10528,94 @@ 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 ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } return new(element); } - case "usage_discount": + case "tiered": { 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) + catch (JsonException) { // ignore } 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 +10623,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; - public JsonElement Json + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); } + init { this._rawData.Set("conversion_rate", value); } } - public string ItemID + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public TieredWithMinimumConversionRateConfig? ConversionRateConfig { 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( + "conversion_rate_config" ); } + init { this._rawData.Set("conversion_rate_config", value); } } - public string Name + /// + /// 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.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("currency"); } + init { this._rawData.Set("currency", value); } } - public string? BillableMetricID + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { 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( + "dimensional_price_configuration" ); } + init { this._rawData.Set("dimensional_price_configuration", value); } } - public bool? BilledInAdvance + /// + /// An alias for the price. + /// + public string? ExternalPriceID { 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.GetNullableClass("external_price_id"); } + init { this._rawData.Set("external_price_id", value); } } - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity { 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.GetNullableStruct("fixed_price_quantity"); } + init { this._rawData.Set("fixed_price_quantity", value); } } - public double? ConversionRate + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey { 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("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( - 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( + "invoicing_cycle_configuration" ); } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { 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("license_type_id"); } + init { this._rawData.Set("license_type_id", value); } } - public string? ExternalPriceID + /// + /// User-specified key/value pairs for the resource. Individual keys can be 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.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.Freeze(); + return this._rawData.GetNullableClass>("metadata"); } - } - - public double? FixedPriceQuantity - { - get + init { - 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.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) ); } } - public string? InvoiceGroupingKey + /// + /// 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.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 - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); } + init { this._rawData.Set("reference_id", value); } } - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + /// + public override void Validate() { - get + this.Cadence.Validate(); + _ = this.ItemID; + foreach (var item in this.LicenseAllocations) { - 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 - ); + item.Validate(); } - } - - public string? ReferenceID - { - get + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_with_minimum") + ) + ) { - 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 - ); + 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 ReplacePricePrice(NewPlanUnitPrice value, JsonElement? element = null) + public TieredWithMinimum() { - this.Value = value; - this._element = element; + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_minimum"); } - public ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithMinimum(TieredWithMinimum tieredWithMinimum) + : base(tieredWithMinimum) { } +#pragma warning restore CS8618 + + 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) +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 ) + : base(tieredWithMinimumLicenseAllocation) { } +#pragma warning restore CS8618 + + public TieredWithMinimumLicenseAllocation(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public ReplacePricePrice(NewPlanPackageWithAllocationPrice 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(NewPlanUnitWithPercentPrice value, JsonElement? element = null) + /// + public static TieredWithMinimumLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public ReplacePricePrice(NewPlanMatrixWithAllocationPrice 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( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration 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(NewPlanUnitWithProrationPrice 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(NewPlanGroupedAllocationPrice 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(NewPlanBulkWithProrationPrice 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( - NewPlanGroupedWithProratedMinimumPrice 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( - NewPlanGroupedWithMeteredMinimumPrice value, - JsonElement? element = null + /// + public static TieredWithMinimumConfig FromRawUnchecked( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null - ) + [SetsRequiredMembers] + public TieredWithMinimumConfig(IReadOnlyList tiers) + : this() { - this.Value = value; - this._element = element; + this.Tiers = tiers; } +} - public ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice 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(NewPlanGroupedTieredPackagePrice 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(NewPlanMaxGroupTieredPackagePrice 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( - NewPlanScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.MinimumAmount; + _ = this.TierLowerBound; + _ = this.UnitAmount; } - public ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice 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(NewPlanCumulativeGroupedBulkPrice 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( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null + /// + public static TieredWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } +class TieredWithMinimumConfigTierFromRaw : IFromRawJson +{ + /// + public TieredWithMinimumConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithMinimumConfigTier.FromRawUnchecked(rawData); +} - public ReplacePricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) +[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 +11393,8 @@ public ReplacePricePrice( this._element = element; } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value, + public TieredWithMinimumConversionRateConfig( + SharedTieredConversionRateConfig value, JsonElement? element = null ) { @@ -11239,1224 +11402,1112 @@ 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. + /// 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. + /// 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. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. /// - /// Consider using or if you need to handle every variant. + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// /// /// /// - /// if (instance.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. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. /// - /// Consider using or if you need to handle every variant. + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// /// /// /// - /// if (instance.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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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() + { + 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 ) { - value = this.Value as NewPlanMinimumCompositePrice; - 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), + }; } - /// - /// Returns true and sets the 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 override void Write( + Utf8JsonWriter writer, + GroupedTieredCadence value, + JsonSerializerOptions options ) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent; - return value != null; + 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 +{ /// - /// Returns true and sets the 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); - /// } - /// - /// + /// The billable metric property used to group before tiering /// - public bool TryPickEventOutput( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput? value - ) + public required string GroupingKey { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } } /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, - /// (NewPlanGroupedTieredPackagePrice value) => {...}, - /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, - /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// + /// Apply tiered pricing to each segment generated after grouping with the provided key /// - 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 - ) + public required IReadOnlyList Tiers { - switch (this.Value) + get { - case NewPlanUnitPrice value: - newPlanUnit(value); - break; - case NewPlanTieredPrice value: - newPlanTiered(value); - break; - case NewPlanBulkPrice value: - newPlanBulk(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value: - bulkWithFilters(value); - break; - case NewPlanPackagePrice value: - newPlanPackage(value); - break; - case NewPlanMatrixPrice value: - newPlanMatrix(value); - break; - case NewPlanThresholdTotalAmountPrice value: - newPlanThresholdTotalAmount(value); - break; - case NewPlanTieredPackagePrice value: - newPlanTieredPackage(value); - break; - case NewPlanTieredWithMinimumPrice value: - newPlanTieredWithMinimum(value); - break; - case NewPlanGroupedTieredPrice value: - newPlanGroupedTiered(value); - break; - case NewPlanTieredPackageWithMinimumPrice value: - newPlanTieredPackageWithMinimum(value); - break; - case NewPlanPackageWithAllocationPrice value: - newPlanPackageWithAllocation(value); - break; - case NewPlanUnitWithPercentPrice value: - newPlanUnitWithPercent(value); - break; - case NewPlanMatrixWithAllocationPrice value: - newPlanMatrixWithAllocation(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value: - tieredWithProration(value); - break; - case NewPlanUnitWithProrationPrice value: - newPlanUnitWithProration(value); - break; - case NewPlanGroupedAllocationPrice value: - newPlanGroupedAllocation(value); - break; - case NewPlanBulkWithProrationPrice value: - newPlanBulkWithProration(value); - break; - case NewPlanGroupedWithProratedMinimumPrice value: - newPlanGroupedWithProratedMinimum(value); - break; - case NewPlanGroupedWithMeteredMinimumPrice value: - newPlanGroupedWithMeteredMinimum(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value: - groupedWithMinMaxThresholds(value); - break; - case NewPlanMatrixWithDisplayNamePrice value: - newPlanMatrixWithDisplayName(value); - break; - case NewPlanGroupedTieredPackagePrice value: - newPlanGroupedTieredPackage(value); - break; - case NewPlanMaxGroupTieredPackagePrice value: - newPlanMaxGroupTieredPackage(value); - break; - case NewPlanScalableMatrixWithUnitPricingPrice value: - newPlanScalableMatrixWithUnitPricing(value); - break; - case NewPlanScalableMatrixWithTieredPricingPrice value: - newPlanScalableMatrixWithTieredPricing(value); - break; - case NewPlanCumulativeGroupedBulkPrice value: - newPlanCumulativeGroupedBulk(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value: - cumulativeGroupedAllocation(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value: - minimum(value); - break; - case NewPlanMinimumCompositePrice value: - newPlanMinimumComposite(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value: - percent(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value: - eventOutput(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("tiers"); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (NewPlanUnitPrice value) => {...}, - /// (NewPlanTieredPrice value) => {...}, - /// (NewPlanBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value) => {...}, - /// (NewPlanPackagePrice value) => {...}, - /// (NewPlanMatrixPrice value) => {...}, - /// (NewPlanThresholdTotalAmountPrice value) => {...}, - /// (NewPlanTieredPackagePrice value) => {...}, - /// (NewPlanTieredWithMinimumPrice value) => {...}, - /// (NewPlanGroupedTieredPrice value) => {...}, - /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, - /// (NewPlanPackageWithAllocationPrice value) => {...}, - /// (NewPlanUnitWithPercentPrice value) => {...}, - /// (NewPlanMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value) => {...}, - /// (NewPlanUnitWithProrationPrice value) => {...}, - /// (NewPlanGroupedAllocationPrice value) => {...}, - /// (NewPlanBulkWithProrationPrice value) => {...}, - /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, - /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, - /// (NewPlanGroupedTieredPackagePrice value) => {...}, - /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, - /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value) => {...}, - /// (NewPlanMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value) => {...}, - /// (global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func newPlanUnit, - System::Func newPlanTiered, - System::Func newPlanBulk, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters, - T - > bulkWithFilters, - System::Func newPlanPackage, - System::Func newPlanMatrix, - System::Func newPlanThresholdTotalAmount, - System::Func newPlanTieredPackage, - System::Func newPlanTieredWithMinimum, - System::Func newPlanGroupedTiered, - System::Func newPlanTieredPackageWithMinimum, - System::Func newPlanPackageWithAllocation, - System::Func newPlanUnitWithPercent, - System::Func newPlanMatrixWithAllocation, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration, - T - > tieredWithProration, - System::Func newPlanUnitWithProration, - System::Func newPlanGroupedAllocation, - System::Func newPlanBulkWithProration, - System::Func newPlanGroupedWithProratedMinimum, - System::Func newPlanGroupedWithMeteredMinimum, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds, - T - > groupedWithMinMaxThresholds, - System::Func newPlanMatrixWithDisplayName, - System::Func newPlanGroupedTieredPackage, - System::Func newPlanMaxGroupTieredPackage, - System::Func< - NewPlanScalableMatrixWithUnitPricingPrice, - T - > newPlanScalableMatrixWithUnitPricing, - System::Func< - NewPlanScalableMatrixWithTieredPricingPrice, - T - > newPlanScalableMatrixWithTieredPricing, - System::Func newPlanCumulativeGroupedBulk, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation, - T - > cumulativeGroupedAllocation, - System::Func minimum, - System::Func newPlanMinimumComposite, - System::Func percent, - System::Func< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput, - T - > eventOutput - ) + /// + public override void Validate() { - return this.Value switch + _ = this.GroupingKey; + foreach (var item in this.Tiers) { - NewPlanUnitPrice value => newPlanUnit(value), - NewPlanTieredPrice value => newPlanTiered(value), - NewPlanBulkPrice value => newPlanBulk(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value => - bulkWithFilters(value), - NewPlanPackagePrice value => newPlanPackage(value), - NewPlanMatrixPrice value => newPlanMatrix(value), - NewPlanThresholdTotalAmountPrice value => newPlanThresholdTotalAmount(value), - NewPlanTieredPackagePrice value => newPlanTieredPackage(value), - NewPlanTieredWithMinimumPrice value => newPlanTieredWithMinimum(value), - NewPlanGroupedTieredPrice value => newPlanGroupedTiered(value), - NewPlanTieredPackageWithMinimumPrice value => newPlanTieredPackageWithMinimum(value), - NewPlanPackageWithAllocationPrice value => newPlanPackageWithAllocation(value), - NewPlanUnitWithPercentPrice value => newPlanUnitWithPercent(value), - NewPlanMatrixWithAllocationPrice value => newPlanMatrixWithAllocation(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value => - tieredWithProration(value), - NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), - NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), - NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), - NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( - value - ), - NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value => - groupedWithMinMaxThresholds(value), - NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), - NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), - NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), - NewPlanScalableMatrixWithUnitPricingPrice value => newPlanScalableMatrixWithUnitPricing( - value - ), - NewPlanScalableMatrixWithTieredPricingPrice value => - newPlanScalableMatrixWithTieredPricing(value), - NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value => - cumulativeGroupedAllocation(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value => minimum(value), - NewPlanMinimumCompositePrice value => newPlanMinimumComposite(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value => percent(value), - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value => - eventOutput(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ), - }; + item.Validate(); + } } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanUnitPrice value - ) => new(value); + public GroupedTieredConfig() { } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredPrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredConfig(GroupedTieredConfig groupedTieredConfig) + : base(groupedTieredConfig) { } +#pragma warning restore CS8618 - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanBulkPrice value - ) => new(value); + public GroupedTieredConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanPackagePrice value - ) => new(value); + /// + public static GroupedTieredConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMatrixPrice value - ) => new(value); +class GroupedTieredConfigFromRaw : IFromRawJson +{ + /// + public GroupedTieredConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + GroupedTieredConfig.FromRawUnchecked(rawData); +} - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanThresholdTotalAmountPrice value - ) => new(value); +/// +/// 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); } + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredPackagePrice value - ) => new(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 static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredWithMinimumPrice value - ) => new(value); + /// + public override void Validate() + { + _ = this.TierLowerBound; + _ = this.UnitAmount; + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedTieredPrice value - ) => new(value); + public GroupedTieredConfigTier() { } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredPackageWithMinimumPrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredConfigTier(GroupedTieredConfigTier groupedTieredConfigTier) + : base(groupedTieredConfigTier) { } +#pragma warning restore CS8618 - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanPackageWithAllocationPrice value - ) => new(value); + public GroupedTieredConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanUnitWithPercentPrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMatrixWithAllocationPrice value - ) => new(value); + /// + public static GroupedTieredConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value - ) => new(value); +class GroupedTieredConfigTierFromRaw : IFromRawJson +{ + /// + public GroupedTieredConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredConfigTier.FromRawUnchecked(rawData); +} - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanUnitWithProrationPrice value - ) => new(value); +[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); } + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedAllocationPrice value - ) => new(value); + /// + /// The currency of the license allocation. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanBulkWithProrationPrice value - ) => new(value); + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); + } + init { this._rawData.Set("write_off_overage", value); } + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); + public GroupedTieredLicenseAllocation() { } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredLicenseAllocation( + GroupedTieredLicenseAllocation groupedTieredLicenseAllocation + ) + : base(groupedTieredLicenseAllocation) { } +#pragma warning restore CS8618 - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMatrixWithDisplayNamePrice value - ) => new(value); + public GroupedTieredLicenseAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedTieredPackagePrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredLicenseAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMaxGroupTieredPackagePrice value - ) => new(value); + /// + public static GroupedTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); +class GroupedTieredLicenseAllocationFromRaw : IFromRawJson +{ + /// + public GroupedTieredLicenseAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredLicenseAllocation.FromRawUnchecked(rawData); +} - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); +[JsonConverter(typeof(GroupedTieredConversionRateConfigConverter))] +public record class GroupedTieredConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanCumulativeGroupedBulkPrice value - ) => new(value); + JsonElement? _element = null; - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value - ) => new(value); + public GroupedTieredConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMinimumCompositePrice value - ) => new(value); + 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 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 +12525,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,47 +12542,58 @@ 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 ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -12577,899 +12604,235 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } 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 - } + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } + } - 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 - } + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } + } - 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 - } + /// + /// 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); } + } - 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 - } + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } + } - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_prorated_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_metered_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix_with_display_name": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_tiered_package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "max_group_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_unit_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_tiered_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_bulk": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum_composite": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "percent": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "event_output": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value?.Json, options); - } -} - -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFilters : JsonModel -{ - /// - /// Configuration for bulk_with_filters pricing - /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); - } - init { this._rawData.Set("bulk_with_filters_config", value); } - } - - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence - > Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence - > - >("cadence"); - } - init { this._rawData.Set("cadence", value); } - } - - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } - } - - /// - /// The pricing model type - /// - public JsonElement ModelType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } - } - - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } - - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } - } - - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } - - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); - } - init { this._rawData.Set("currency", value); } - } - - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } + } /// /// An alias for the price. @@ -13526,6 +12889,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -13564,19 +12940,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 +12968,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 +13008,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(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel +[JsonConverter(typeof(TieredPackageWithMinimumCadenceConverter))] +public enum TieredPackageWithMinimumCadence { - /// - /// Property filters to apply (all must match) - /// - public required IReadOnlyList Filters + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredPackageWithMinimumCadenceConverter + : JsonConverter +{ + public override TieredPackageWithMinimumCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("filters"); - } - init + return JsonSerializer.Deserialize(ref reader, options) switch { - this._rawData.Set< - ImmutableArray - >("filters", ImmutableArray.ToImmutableArray(value)); - } + "annual" => TieredPackageWithMinimumCadence.Annual, + "semi_annual" => TieredPackageWithMinimumCadence.SemiAnnual, + "monthly" => TieredPackageWithMinimumCadence.Monthly, + "quarterly" => TieredPackageWithMinimumCadence.Quarterly, + "one_time" => TieredPackageWithMinimumCadence.OneTime, + "custom" => TieredPackageWithMinimumCadence.Custom, + _ => (TieredPackageWithMinimumCadence)(-1), + }; } - /// - /// Bulk tiers for rating based on total usage volume - /// - public required IReadOnlyList Tiers + 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.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() + /// + /// The currency of the license allocation. + /// + public required string Currency { - foreach (var item in this.Filters) + get { - item.Validate(); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); } - foreach (var item in this.Tiers) + init { this._rawData.Set("currency", value); } + } + + /// + /// When True, overage beyond the allocation is written off. + /// + public bool? WriteOffOverage + { + get { - item.Validate(); + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("write_off_overage"); } + init { this._rawData.Set("write_off_overage", value); } } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } + /// + public override void Validate() + { + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; + } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig + public TieredPackageWithMinimumLicenseAllocation() { } + +#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 +13150,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 +13165,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 +13259,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,452 +13311,64958 @@ 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 - ); + ) => TieredPackageWithMinimumConfigTier.FromRawUnchecked(rawData); } -/// -/// The cadence to bill for this price on. -/// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadenceConverter) -)] -public enum ReplacePricePriceBulkWithFiltersCadence +[JsonConverter(typeof(TieredPackageWithMinimumConversionRateConfigConverter))] +public record class TieredPackageWithMinimumConversionRateConfig : ModelBase { - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, + 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 ReplacePricePriceBulkWithFiltersCadenceConverter - : JsonConverter +sealed class TieredPackageWithMinimumConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence Read( + public override TieredPackageWithMinimumConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { - return JsonSerializer.Deserialize(ref reader, options) switch + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try { - "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 - ), - }; + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + } + catch + { + conversionRateType = null; + } + + switch (conversionRateType) + { + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + default: + { + return new TieredPackageWithMinimumConversionRateConfig(element); + } + } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersCadence value, + TieredPackageWithMinimumConversionRateConfig 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 - ); + JsonSerializer.Serialize(writer, value.Json, options); } } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFiltersConversionRateConfigConverter) -)] -public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PackageWithAllocation : JsonModel { - public object? Value { get; } = null; + /// + /// 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); } + } - JsonElement? _element = null; + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } - public JsonElement Json + /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. + /// + public required IReadOnlyList LicenseAllocations { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions + 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); } } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } + } + + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } + } + + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } + } + + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate + { + get + { + this._rawData.Freeze(); + return this._rawData.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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_prorated_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_metered_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_min_max_thresholds": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "max_group_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "scalable_matrix_with_unit_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "scalable_matrix_with_tiered_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "cumulative_grouped_bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "cumulative_grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "minimum_composite": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "percent": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "event_output": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "usage_discount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "amount_discount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "maximum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_prorated_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_metered_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_min_max_thresholds": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "max_group_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "scalable_matrix_with_unit_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "scalable_matrix_with_tiered_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "cumulative_grouped_bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "cumulative_grouped_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "minimum_composite": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "percent": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "event_output": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( - 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) - { - this._element = element; - } + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - switch (conversionRateType) - { - case "unit": + return new(element); + } + case "minimum_composite": { 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) + catch (JsonException) { // ignore } return new(element); } - case "tiered": + case "percent": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + catch (JsonException) { // ignore } @@ -14330,47 +78271,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 +78363,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 +78422,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 +78518,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +78569,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 +78593,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 +78635,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 +78697,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 +78726,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( FrozenDictionary rawData ) { @@ -14887,89 +78734,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 +78904,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( FrozenDictionary rawData ) { @@ -14986,31 +78912,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 +79015,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15036,7 +79024,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15045,7 +79033,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -15054,7 +79042,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement elem /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -15075,7 +79063,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -15095,7 +79083,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -15106,8 +79094,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15127,7 +79115,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" ); } } @@ -15136,7 +79124,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -15147,8 +79135,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15163,16 +79151,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 +79179,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 +79196,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 @@ -15245,12 +79244,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -15267,12 +79264,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -15281,16 +79276,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 +79293,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 +79353,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 +79427,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 +79523,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +79575,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 +79598,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 +79640,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 +79663,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 +79674,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 +79694,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 +79710,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 +79868,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -15872,8 +79876,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15881,22 +79885,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 +79913,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15922,7 +79922,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15931,7 +79931,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -15940,7 +79940,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElem /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -15961,7 +79961,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -15981,7 +79981,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -15992,8 +79992,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16013,7 +80013,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" ); } } @@ -16022,7 +80022,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -16033,8 +80033,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16049,16 +80049,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 +80077,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 +80094,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 @@ -16131,12 +80142,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -16153,12 +80162,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -16167,16 +80174,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 +80191,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 +80325,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 +80421,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +80473,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 +80496,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 +80540,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 +80563,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 +80574,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 +80594,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 +80610,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 +80701,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -16758,8 +80709,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16767,22 +80718,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 +80748,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16808,7 +80757,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16817,7 +80766,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -16826,7 +80775,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElem /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -16847,7 +80796,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -16867,7 +80816,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -16878,8 +80827,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16899,7 +80848,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" ); } } @@ -16908,7 +80857,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -16919,8 +80868,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16935,16 +80884,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 +80912,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 +80931,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 @@ -17017,12 +80979,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -17039,12 +80999,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -17053,7 +81011,7 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -17062,7 +81020,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -17072,59 +81030,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 +81164,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 +81260,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +81312,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 +81335,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 +81379,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 +81402,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 +81413,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 +81433,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 +81449,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 +81587,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17639,7 +81596,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17648,7 +81605,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -17657,7 +81614,7 @@ public ReplacePricePriceMinimumConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -17678,7 +81635,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -17698,7 +81655,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -17709,8 +81666,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17730,7 +81687,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" ); } } @@ -17739,7 +81696,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -17750,8 +81707,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17766,16 +81723,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 +81751,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 +81770,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 @@ -17848,12 +81818,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -17870,12 +81838,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -17884,7 +81850,7 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig( + return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -17893,7 +81859,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimumConversionRateConfig value, + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -17902,30 +81868,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 +81929,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 +82000,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 +82096,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +82166,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -18205,10 +82176,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 +82197,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 +82206,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 +82229,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 +82239,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 +82259,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 +82279,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 +82306,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 +82327,8 @@ public ReplacePricePricePercentPercentConfig(IReadOnlyDictionary - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentPercentConfig FromRawUnchecked( + /// + public static ReplacePricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -18408,20 +82344,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; @@ -18466,7 +82397,7 @@ public ReplacePricePricePercentConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -18487,7 +82418,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -18507,7 +82438,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -18518,8 +82449,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18548,7 +82479,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -18559,8 +82490,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18580,11 +82511,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 +82540,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 +82551,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 @@ -18657,12 +82599,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -18679,12 +82619,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -18693,16 +82631,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 +82647,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 +82669,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 +82779,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 +82875,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +82950,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -19019,10 +82960,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 +82981,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 +82990,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 +83013,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 +83023,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 +83043,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 +83063,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 +83121,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 +83144,8 @@ IReadOnlyDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputEventOutputConfig FromRawUnchecked( + /// + public static ReplacePricePriceEventOutputEventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -19274,20 +83161,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; @@ -19332,7 +83214,7 @@ public ReplacePricePriceEventOutputConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -19353,7 +83235,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -19373,7 +83255,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -19384,8 +83266,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19414,7 +83296,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -19425,8 +83307,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19446,11 +83328,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 +83357,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 +83368,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 @@ -19523,12 +83416,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -19545,12 +83436,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -19559,16 +83448,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..8a1c971e7 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, @@ -42,24 +49,62 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] ExternalPlanIDFetchPlanVersionParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalPlanID, + string version ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalPlanID = externalPlanID; + this.Version = version; } #pragma warning restore CS8618 - /// + /// public static ExternalPlanIDFetchPlanVersionParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalPlanID, + string version ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalPlanID, + version + ); + } + + 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) @@ -85,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/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParams.cs index 48f536f06..acde9dc09 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, @@ -63,27 +70,61 @@ IReadOnlyDictionary rawBodyData ExternalPlanIDSetDefaultPlanVersionParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string externalPlanID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ExternalPlanID = externalPlanID; } #pragma warning restore CS8618 - /// + /// public static ExternalPlanIDSetDefaultPlanVersionParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string externalPlanID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + externalPlanID + ); + } + + 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) @@ -117,4 +158,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..441a2571f 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) { @@ -289,7 +292,7 @@ public PlanVersionAdjustment(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -312,7 +315,7 @@ public bool TryPickPlanPhaseUsageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -335,7 +338,7 @@ public bool TryPickPlanPhaseAmountDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -358,7 +361,7 @@ public bool TryPickPlanPhasePercentageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -381,7 +384,7 @@ public bool TryPickPlanPhaseMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -403,7 +406,7 @@ public bool TryPickPlanPhaseMaximum( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -414,11 +417,11 @@ public bool TryPickPlanPhaseMaximum( /// /// /// instance.Switch( - /// (Models::PlanPhaseUsageDiscountAdjustment value) => {...}, - /// (Models::PlanPhaseAmountDiscountAdjustment value) => {...}, - /// (Models::PlanPhasePercentageDiscountAdjustment value) => {...}, - /// (Models::PlanPhaseMinimumAdjustment value) => {...}, - /// (Models::PlanPhaseMaximumAdjustment value) => {...} + /// (Models::PlanPhaseUsageDiscountAdjustment value) => {...}, + /// (Models::PlanPhaseAmountDiscountAdjustment value) => {...}, + /// (Models::PlanPhasePercentageDiscountAdjustment value) => {...}, + /// (Models::PlanPhaseMinimumAdjustment value) => {...}, + /// (Models::PlanPhaseMaximumAdjustment value) => {...} /// ); /// /// @@ -459,7 +462,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -470,11 +473,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (Models::PlanPhaseUsageDiscountAdjustment value) => {...}, - /// (Models::PlanPhaseAmountDiscountAdjustment value) => {...}, - /// (Models::PlanPhasePercentageDiscountAdjustment value) => {...}, - /// (Models::PlanPhaseMinimumAdjustment value) => {...}, - /// (Models::PlanPhaseMaximumAdjustment value) => {...} + /// (Models::PlanPhaseUsageDiscountAdjustment value) => {...}, + /// (Models::PlanPhaseAmountDiscountAdjustment value) => {...}, + /// (Models::PlanPhasePercentageDiscountAdjustment value) => {...}, + /// (Models::PlanPhaseMinimumAdjustment value) => {...}, + /// (Models::PlanPhaseMaximumAdjustment value) => {...} /// ); /// /// @@ -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 @@ -595,12 +614,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -618,12 +635,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -641,12 +656,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -664,12 +677,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -687,12 +698,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } 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..c146e913f 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) { @@ -1516,8 +1532,8 @@ public required string AdjustedSubtotal /// /// All adjustments applied to the line item in the order they were applied based - /// on invoice calculations (ie. usage discounts -> amount discounts -> percentage - /// discounts -> minimums -> maximums). + /// on invoice calculations (ie. usage discounts -> amount discounts -> + /// percentage discounts -> minimums -> maximums). /// public required IReadOnlyList Adjustments { @@ -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) { @@ -1943,7 +1962,7 @@ public LineItemAdjustment(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1966,7 +1985,7 @@ public bool TryPickMonetaryUsageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1989,7 +2008,7 @@ public bool TryPickMonetaryAmountDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2012,7 +2031,7 @@ public bool TryPickMonetaryPercentageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2033,7 +2052,7 @@ public bool TryPickMonetaryMinimum([NotNullWhen(true)] out MonetaryMinimumAdjust /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2053,7 +2072,7 @@ public bool TryPickMonetaryMaximum([NotNullWhen(true)] out MonetaryMaximumAdjust /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2064,11 +2083,11 @@ public bool TryPickMonetaryMaximum([NotNullWhen(true)] out MonetaryMaximumAdjust /// /// /// instance.Switch( - /// (MonetaryUsageDiscountAdjustment value) => {...}, - /// (MonetaryAmountDiscountAdjustment value) => {...}, - /// (MonetaryPercentageDiscountAdjustment value) => {...}, - /// (MonetaryMinimumAdjustment value) => {...}, - /// (MonetaryMaximumAdjustment value) => {...} + /// (MonetaryUsageDiscountAdjustment value) => {...}, + /// (MonetaryAmountDiscountAdjustment value) => {...}, + /// (MonetaryPercentageDiscountAdjustment value) => {...}, + /// (MonetaryMinimumAdjustment value) => {...}, + /// (MonetaryMaximumAdjustment value) => {...} /// ); /// /// @@ -2109,7 +2128,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2120,11 +2139,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MonetaryUsageDiscountAdjustment value) => {...}, - /// (MonetaryAmountDiscountAdjustment value) => {...}, - /// (MonetaryPercentageDiscountAdjustment value) => {...}, - /// (MonetaryMinimumAdjustment value) => {...}, - /// (MonetaryMaximumAdjustment value) => {...} + /// (MonetaryUsageDiscountAdjustment value) => {...}, + /// (MonetaryAmountDiscountAdjustment value) => {...}, + /// (MonetaryPercentageDiscountAdjustment value) => {...}, + /// (MonetaryMinimumAdjustment value) => {...}, + /// (MonetaryMaximumAdjustment value) => {...} /// ); /// /// @@ -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 @@ -2238,12 +2273,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2260,12 +2293,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2283,12 +2314,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2305,12 +2334,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2327,12 +2354,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2438,7 +2463,7 @@ public SubLineItem(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2459,7 +2484,7 @@ public bool TryPickMatrix([NotNullWhen(true)] out MatrixSubLineItem? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2480,7 +2505,7 @@ public bool TryPickTier([NotNullWhen(true)] out TierSubLineItem? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2500,7 +2525,7 @@ public bool TryPickOther([NotNullWhen(true)] out OtherSubLineItem? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2511,9 +2536,9 @@ public bool TryPickOther([NotNullWhen(true)] out OtherSubLineItem? value) /// /// /// instance.Switch( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -2544,7 +2569,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2555,9 +2580,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -2606,10 +2631,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 +2642,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 @@ -2651,12 +2690,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2673,12 +2710,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2695,12 +2730,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2835,8 +2868,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..8f6921e29 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) { @@ -197,7 +200,7 @@ public CouponDiscount(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -218,7 +221,7 @@ public bool TryPickPercentage([NotNullWhen(true)] out PercentageDiscount? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -238,7 +241,7 @@ public bool TryPickAmount([NotNullWhen(true)] out AmountDiscount? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -249,8 +252,8 @@ public bool TryPickAmount([NotNullWhen(true)] out AmountDiscount? value) /// /// /// instance.Switch( - /// (PercentageDiscount value) => {...}, - /// (AmountDiscount value) => {...} + /// (PercentageDiscount value) => {...}, + /// (AmountDiscount value) => {...} /// ); /// /// @@ -279,7 +282,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -290,8 +293,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (PercentageDiscount value) => {...}, - /// (AmountDiscount value) => {...} + /// (PercentageDiscount value) => {...}, + /// (AmountDiscount value) => {...} /// ); /// /// @@ -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 @@ -379,12 +395,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -398,12 +412,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Coupons/CouponArchiveParams.cs b/src/Orb/Models/Coupons/CouponArchiveParams.cs index c952ddf51..738faa32c 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, @@ -38,24 +45,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CouponArchiveParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string couponID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CouponID = couponID; } #pragma warning restore CS8618 - /// + /// public static CouponArchiveParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string couponID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + couponID + ); + } + + 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) @@ -77,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/Coupons/CouponCreateParams.cs b/src/Orb/Models/Coupons/CouponCreateParams.cs index 036e75ba0..4a57db6da 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, @@ -109,7 +114,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static CouponCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -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))] @@ -194,7 +232,7 @@ public Discount(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -215,7 +253,7 @@ public bool TryPickPercentage([NotNullWhen(true)] out Percentage? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -235,7 +273,7 @@ public bool TryPickAmount([NotNullWhen(true)] out Amount? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -246,8 +284,8 @@ public bool TryPickAmount([NotNullWhen(true)] out Amount? value) /// /// /// instance.Switch( - /// (Percentage value) => {...}, - /// (Amount value) => {...} + /// (Percentage value) => {...}, + /// (Amount value) => {...} /// ); /// /// @@ -271,7 +309,7 @@ public void Switch(System::Action percentage, System::Action /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -282,8 +320,8 @@ public void Switch(System::Action percentage, System::Action /// /// /// var result = instance.Match( - /// (Percentage value) => {...}, - /// (Amount value) => {...} + /// (Percentage value) => {...}, + /// (Amount value) => {...} /// ); /// /// @@ -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 @@ -364,12 +414,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -383,12 +431,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -397,16 +443,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 +497,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 +577,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..16776c13c 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, @@ -37,24 +44,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CouponFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string couponID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CouponID = couponID; } #pragma warning restore CS8618 - /// + /// public static CouponFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string couponID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + couponID + ); + } + + 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) @@ -75,4 +114,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/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..99edc267c 100644 --- a/src/Orb/Models/Coupons/CouponListParams.cs +++ b/src/Orb/Models/Coupons/CouponListParams.cs @@ -13,10 +13,13 @@ namespace Orb.Models.Coupons; /// /// The list of coupons is ordered starting from the most recently created /// 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. +/// 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 CouponListParams : ParamsBase +public record class CouponListParams : ParamsBase { /// /// Cursor for pagination. This can be populated by the `next_cursor` value returned @@ -81,8 +84,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, @@ -105,7 +111,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static CouponListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -117,6 +123,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 +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/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..ca6442f00 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, @@ -74,24 +81,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] SubscriptionListParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string couponID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CouponID = couponID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string couponID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + couponID + ); + } + + 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) @@ -113,4 +152,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..a6e15eb34 100644 --- a/src/Orb/Models/CreditBlocks/CreditBlockDeleteParams.cs +++ b/src/Orb/Models/CreditBlocks/CreditBlockDeleteParams.cs @@ -17,21 +17,28 @@ namespace Orb.Models.CreditBlocks; /// purchase of the credit block, they will be deleted if in draft status, voided /// if issued, or a credit note will be issued if the invoice is paid. /// -/// 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> 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> +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking 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, @@ -46,26 +53,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CreditBlockDeleteParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string blockID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.BlockID = blockID; } #pragma warning restore CS8618 - /// + /// public static CreditBlockDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string blockID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + blockID ); } + 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 +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/CreditBlocks/CreditBlockListInvoicesParams.cs b/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesParams.cs new file mode 100644 index 000000000..fbffe909c --- /dev/null +++ b/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesParams.cs @@ -0,0 +1,137 @@ +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, + string blockID + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this.BlockID = blockID; + } +#pragma warning restore CS8618 + + /// + public static CreditBlockListInvoicesParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + string blockID + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + blockID + ); + } + + 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..98fc9459d 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, @@ -36,24 +43,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CreditBlockRetrieveParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string blockID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.BlockID = blockID; } #pragma warning restore CS8618 - /// + /// public static CreditBlockRetrieveParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string blockID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + blockID + ); + } + + 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) @@ -75,4 +114,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/CreditBlocks/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..bc913a3f3 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, @@ -160,7 +163,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static CreditNoteCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -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..6c4c3c37d 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, @@ -37,24 +44,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CreditNoteFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string creditNoteID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CreditNoteID = creditNoteID; } #pragma warning restore CS8618 - /// + /// public static CreditNoteFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string creditNoteID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + creditNoteID + ); + } + + 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) @@ -76,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/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..d0ddd239b 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, @@ -116,7 +123,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static CreditNoteListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -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..f120bb830 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, @@ -88,29 +95,63 @@ IReadOnlyDictionary rawBodyData BalanceTransactionCreateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static BalanceTransactionCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + customerID ); } + 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 +180,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..2ddbccb66 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, @@ -129,26 +136,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] BalanceTransactionListParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static BalanceTransactionListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID ); } + 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 +207,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..4b682df8b 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, @@ -188,24 +195,61 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CostListByExternalIDParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static CostListByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalCustomerID + ); + } + + 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) @@ -230,6 +274,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..2e328ec7d 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, @@ -186,24 +193,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CostListParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static CostListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID + ); + } + + 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) @@ -225,6 +264,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..a2e597622 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, @@ -112,26 +164,63 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CreditListByExternalIDParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static CreditListByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalCustomerID ); } + 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 +243,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..7e02bc155 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, @@ -112,26 +164,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CreditListParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static CreditListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID ); } + 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 +235,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..663d559e4 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/DecrementLedgerEntry.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/DecrementLedgerEntry.cs @@ -158,6 +158,11 @@ public required double StartingBalance init { this._rawData.Set("starting_balance", value); } } + /// + /// This field is deprecated and will always be null. Decrements are not associated + /// with individual events. + /// + [System::Obsolete("deprecated")] public string? EventID { get @@ -211,8 +216,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..be2bd4edb 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,14 +99,14 @@ 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 - { - get { return this._rawBodyData.Freeze(); } - } + public JsonElement RawBodyData { get; private init; } public string? ExternalCustomerID { get; init; } @@ -109,16 +114,18 @@ public required LedgerCreateEntryByExternalIDParamsBody Body { get { - this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullClass( - "body" + return WrappedJsonSerializer.GetNotNullClass( + this.RawBodyData, + "RawBodyData" ); } - init { this._rawBodyData.Set("body", value); } + init { this.RawBodyData = JsonSerializer.SerializeToElement(value); } } public LedgerCreateEntryByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParams( LedgerCreateEntryByExternalIDParams ledgerCreateEntryByExternalIDParams ) @@ -126,18 +133,19 @@ LedgerCreateEntryByExternalIDParams ledgerCreateEntryByExternalIDParams { this.ExternalCustomerID = ledgerCreateEntryByExternalIDParams.ExternalCustomerID; - this._rawBodyData = new(ledgerCreateEntryByExternalIDParams._rawBodyData); + this.RawBodyData = ledgerCreateEntryByExternalIDParams.RawBodyData; } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParams( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + JsonElement rawBodyData ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; } #pragma warning disable CS8618 @@ -145,27 +153,66 @@ IReadOnlyDictionary rawBodyData LedgerCreateEntryByExternalIDParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + JsonElement rawBodyData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static LedgerCreateEntryByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + JsonElement rawBodyData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + rawBodyData, + externalCustomerID + ); + } + + 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), + } + ), + 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) @@ -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))] @@ -357,7 +409,7 @@ public LedgerCreateEntryByExternalIDParamsBody(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -380,7 +432,7 @@ public bool TryPickIncrement( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -403,7 +455,7 @@ public bool TryPickDecrement( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -426,7 +478,7 @@ public bool TryPickExpirationChange( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -449,7 +501,7 @@ public bool TryPickVoid( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -471,7 +523,7 @@ public bool TryPickAmendment( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -482,11 +534,11 @@ public bool TryPickAmendment( /// /// /// instance.Switch( - /// (LedgerCreateEntryByExternalIDParamsBodyIncrement value) => {...}, - /// (LedgerCreateEntryByExternalIDParamsBodyDecrement value) => {...}, - /// (LedgerCreateEntryByExternalIDParamsBodyExpirationChange value) => {...}, - /// (LedgerCreateEntryByExternalIDParamsBodyVoid value) => {...}, - /// (LedgerCreateEntryByExternalIDParamsBodyAmendment value) => {...} + /// (LedgerCreateEntryByExternalIDParamsBodyIncrement value) => {...}, + /// (LedgerCreateEntryByExternalIDParamsBodyDecrement value) => {...}, + /// (LedgerCreateEntryByExternalIDParamsBodyExpirationChange value) => {...}, + /// (LedgerCreateEntryByExternalIDParamsBodyVoid value) => {...}, + /// (LedgerCreateEntryByExternalIDParamsBodyAmendment value) => {...} /// ); /// /// @@ -527,7 +579,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -538,11 +590,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (LedgerCreateEntryByExternalIDParamsBodyIncrement value) => {...}, - /// (LedgerCreateEntryByExternalIDParamsBodyDecrement value) => {...}, - /// (LedgerCreateEntryByExternalIDParamsBodyExpirationChange value) => {...}, - /// (LedgerCreateEntryByExternalIDParamsBodyVoid value) => {...}, - /// (LedgerCreateEntryByExternalIDParamsBodyAmendment value) => {...} + /// (LedgerCreateEntryByExternalIDParamsBodyIncrement value) => {...}, + /// (LedgerCreateEntryByExternalIDParamsBodyDecrement value) => {...}, + /// (LedgerCreateEntryByExternalIDParamsBodyExpirationChange value) => {...}, + /// (LedgerCreateEntryByExternalIDParamsBodyVoid value) => {...}, + /// (LedgerCreateEntryByExternalIDParamsBodyAmendment value) => {...} /// ); /// /// @@ -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 @@ -664,12 +732,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -687,12 +753,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -710,12 +774,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -733,12 +795,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -756,12 +816,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -973,10 +1031,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 +1157,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 +1370,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 +1409,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 +1451,7 @@ public override void Validate() this.CustomDueDate?.Validate(); this.InvoiceDate?.Validate(); _ = this.ItemID; + _ = this.MarkAsPaid; _ = this.Memo; _ = this.NetTerms; _ = this.RequireSuccessfulPayment; @@ -1373,10 +1459,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 @@ -1474,7 +1563,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1495,7 +1584,7 @@ public bool TryPickDate([NotNullWhen(true)] out string? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1515,7 +1604,7 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1526,8 +1615,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1556,7 +1645,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1567,8 +1656,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1618,10 +1707,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 +1718,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 +1759,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) { @@ -1732,7 +1837,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1753,7 +1858,7 @@ public bool TryPickDate([NotNullWhen(true)] out string? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1773,7 +1878,7 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1784,8 +1889,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1814,7 +1919,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1825,8 +1930,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1876,10 +1981,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 +1992,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 +2033,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 +2156,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 +2356,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 +2538,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 +2740,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..195d50477 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponse.cs @@ -306,7 +306,7 @@ public LedgerCreateEntryByExternalIDResponse(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -327,7 +327,7 @@ public bool TryPickIncrementLedgerEntry([NotNullWhen(true)] out IncrementLedgerE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -348,7 +348,7 @@ public bool TryPickDecrementLedgerEntry([NotNullWhen(true)] out DecrementLedgerE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -371,7 +371,7 @@ public bool TryPickExpirationChangeLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -394,7 +394,7 @@ public bool TryPickCreditBlockExpiryLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -415,7 +415,7 @@ public bool TryPickVoidLedgerEntry([NotNullWhen(true)] out VoidLedgerEntry? valu /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -438,7 +438,7 @@ public bool TryPickVoidInitiatedLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -458,7 +458,7 @@ public bool TryPickAmendmentLedgerEntry([NotNullWhen(true)] out AmendmentLedgerE /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -469,13 +469,13 @@ public bool TryPickAmendmentLedgerEntry([NotNullWhen(true)] out AmendmentLedgerE /// /// /// instance.Switch( - /// (IncrementLedgerEntry value) => {...}, - /// (DecrementLedgerEntry value) => {...}, - /// (ExpirationChangeLedgerEntry value) => {...}, - /// (CreditBlockExpiryLedgerEntry value) => {...}, - /// (VoidLedgerEntry value) => {...}, - /// (VoidInitiatedLedgerEntry value) => {...}, - /// (AmendmentLedgerEntry value) => {...} + /// (IncrementLedgerEntry value) => {...}, + /// (DecrementLedgerEntry value) => {...}, + /// (ExpirationChangeLedgerEntry value) => {...}, + /// (CreditBlockExpiryLedgerEntry value) => {...}, + /// (VoidLedgerEntry value) => {...}, + /// (VoidInitiatedLedgerEntry value) => {...}, + /// (AmendmentLedgerEntry value) => {...} /// ); /// /// @@ -524,7 +524,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -535,13 +535,13 @@ public void Switch( /// /// /// var result = instance.Match( - /// (IncrementLedgerEntry value) => {...}, - /// (DecrementLedgerEntry value) => {...}, - /// (ExpirationChangeLedgerEntry value) => {...}, - /// (CreditBlockExpiryLedgerEntry value) => {...}, - /// (VoidLedgerEntry value) => {...}, - /// (VoidInitiatedLedgerEntry value) => {...}, - /// (AmendmentLedgerEntry value) => {...} + /// (IncrementLedgerEntry value) => {...}, + /// (DecrementLedgerEntry value) => {...}, + /// (ExpirationChangeLedgerEntry value) => {...}, + /// (CreditBlockExpiryLedgerEntry value) => {...}, + /// (VoidLedgerEntry value) => {...}, + /// (VoidInitiatedLedgerEntry value) => {...}, + /// (AmendmentLedgerEntry value) => {...} /// ); /// /// @@ -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 @@ -673,12 +691,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -695,12 +711,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -717,12 +731,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -739,12 +751,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -761,12 +771,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -783,12 +791,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -805,12 +811,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs index 47c8a79f9..a3653d6b7 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,46 +99,45 @@ 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 - { - get { return this._rawBodyData.Freeze(); } - } + public JsonElement RawBodyData { get; private init; } public string? CustomerID { get; init; } public required Body Body { - get - { - this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullClass("body"); - } - init { this._rawBodyData.Set("body", value); } + get { return WrappedJsonSerializer.GetNotNullClass(this.RawBodyData, "RawBodyData"); } + init { this.RawBodyData = JsonSerializer.SerializeToElement(value); } } public LedgerCreateEntryParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryParams(LedgerCreateEntryParams ledgerCreateEntryParams) : base(ledgerCreateEntryParams) { this.CustomerID = ledgerCreateEntryParams.CustomerID; - this._rawBodyData = new(ledgerCreateEntryParams._rawBodyData); + this.RawBodyData = ledgerCreateEntryParams.RawBodyData; } +#pragma warning restore CS8618 public LedgerCreateEntryParams( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + JsonElement rawBodyData ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; } #pragma warning disable CS8618 @@ -141,29 +145,63 @@ IReadOnlyDictionary rawBodyData LedgerCreateEntryParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + JsonElement rawBodyData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static LedgerCreateEntryParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + JsonElement rawBodyData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + rawBodyData, + customerID ); } + 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), + } + ), + 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 +230,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(BodyConverter))] @@ -335,7 +378,7 @@ public Body(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -356,7 +399,7 @@ public bool TryPickIncrement([NotNullWhen(true)] out Increment? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -377,7 +420,7 @@ public bool TryPickDecrement([NotNullWhen(true)] out Decrement? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -398,7 +441,7 @@ public bool TryPickExpirationChange([NotNullWhen(true)] out ExpirationChange? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -419,7 +462,7 @@ public bool TryPickVoid([NotNullWhen(true)] out Void? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -439,7 +482,7 @@ public bool TryPickAmendment([NotNullWhen(true)] out Amendment? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -450,11 +493,11 @@ public bool TryPickAmendment([NotNullWhen(true)] out Amendment? value) /// /// /// instance.Switch( - /// (Increment value) => {...}, - /// (Decrement value) => {...}, - /// (ExpirationChange value) => {...}, - /// (Void value) => {...}, - /// (Amendment value) => {...} + /// (Increment value) => {...}, + /// (Decrement value) => {...}, + /// (ExpirationChange value) => {...}, + /// (Void value) => {...}, + /// (Amendment value) => {...} /// ); /// /// @@ -493,7 +536,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -504,11 +547,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (Increment value) => {...}, - /// (Decrement value) => {...}, - /// (ExpirationChange value) => {...}, - /// (Void value) => {...}, - /// (Amendment value) => {...} + /// (Increment value) => {...}, + /// (Decrement value) => {...}, + /// (ExpirationChange value) => {...}, + /// (Void value) => {...}, + /// (Amendment value) => {...} /// ); /// /// @@ -567,10 +610,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 +621,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 @@ -609,12 +668,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -628,12 +685,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -650,12 +705,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -669,12 +722,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -688,12 +739,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -800,18 +849,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 +941,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 +986,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 +1005,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 +1044,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 +1063,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 +1096,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 +1120,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 +1137,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 +1225,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 +1264,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 +1306,7 @@ public override void Validate() this.CustomDueDate?.Validate(); this.InvoiceDate?.Validate(); _ = this.ItemID; + _ = this.MarkAsPaid; _ = this.Memo; _ = this.NetTerms; _ = this.RequireSuccessfulPayment; @@ -1259,8 +1314,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) { @@ -1339,7 +1397,7 @@ public CustomDueDate(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1360,7 +1418,7 @@ public bool TryPickDate([NotNullWhen(true)] out string? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1380,7 +1438,7 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1391,8 +1449,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1421,7 +1479,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1432,8 +1490,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1475,10 +1533,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 +1544,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 +1584,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) { @@ -1577,7 +1651,7 @@ public InvoiceDate(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1598,7 +1672,7 @@ public bool TryPickDate([NotNullWhen(true)] out string? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1618,7 +1692,7 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1629,8 +1703,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1657,7 +1731,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1668,8 +1742,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1709,10 +1783,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 +1794,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 +1834,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 +1952,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 +2139,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 +2306,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 +2494,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..2c61f6998 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryResponse.cs @@ -291,7 +291,7 @@ public LedgerCreateEntryResponse(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -312,7 +312,7 @@ public bool TryPickIncrementLedgerEntry([NotNullWhen(true)] out IncrementLedgerE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -333,7 +333,7 @@ public bool TryPickDecrementLedgerEntry([NotNullWhen(true)] out DecrementLedgerE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -356,7 +356,7 @@ public bool TryPickExpirationChangeLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -379,7 +379,7 @@ public bool TryPickCreditBlockExpiryLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -400,7 +400,7 @@ public bool TryPickVoidLedgerEntry([NotNullWhen(true)] out VoidLedgerEntry? valu /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -423,7 +423,7 @@ public bool TryPickVoidInitiatedLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -443,7 +443,7 @@ public bool TryPickAmendmentLedgerEntry([NotNullWhen(true)] out AmendmentLedgerE /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -454,13 +454,13 @@ public bool TryPickAmendmentLedgerEntry([NotNullWhen(true)] out AmendmentLedgerE /// /// /// instance.Switch( - /// (IncrementLedgerEntry value) => {...}, - /// (DecrementLedgerEntry value) => {...}, - /// (ExpirationChangeLedgerEntry value) => {...}, - /// (CreditBlockExpiryLedgerEntry value) => {...}, - /// (VoidLedgerEntry value) => {...}, - /// (VoidInitiatedLedgerEntry value) => {...}, - /// (AmendmentLedgerEntry value) => {...} + /// (IncrementLedgerEntry value) => {...}, + /// (DecrementLedgerEntry value) => {...}, + /// (ExpirationChangeLedgerEntry value) => {...}, + /// (CreditBlockExpiryLedgerEntry value) => {...}, + /// (VoidLedgerEntry value) => {...}, + /// (VoidInitiatedLedgerEntry value) => {...}, + /// (AmendmentLedgerEntry value) => {...} /// ); /// /// @@ -509,7 +509,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -520,13 +520,13 @@ public void Switch( /// /// /// var result = instance.Match( - /// (IncrementLedgerEntry value) => {...}, - /// (DecrementLedgerEntry value) => {...}, - /// (ExpirationChangeLedgerEntry value) => {...}, - /// (CreditBlockExpiryLedgerEntry value) => {...}, - /// (VoidLedgerEntry value) => {...}, - /// (VoidInitiatedLedgerEntry value) => {...}, - /// (AmendmentLedgerEntry value) => {...} + /// (IncrementLedgerEntry value) => {...}, + /// (DecrementLedgerEntry value) => {...}, + /// (ExpirationChangeLedgerEntry value) => {...}, + /// (CreditBlockExpiryLedgerEntry value) => {...}, + /// (VoidLedgerEntry value) => {...}, + /// (VoidInitiatedLedgerEntry value) => {...}, + /// (AmendmentLedgerEntry value) => {...} /// ); /// /// @@ -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 @@ -650,12 +668,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -672,12 +688,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -694,12 +708,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -716,12 +728,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -738,12 +748,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -760,12 +768,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -782,12 +788,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } 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..6b5677d2b 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, @@ -225,24 +229,61 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] LedgerListByExternalIDParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static LedgerListByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalCustomerID + ); + } + + 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) @@ -267,6 +308,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..f60fa2ac7 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponse.cs @@ -297,7 +297,7 @@ public LedgerListByExternalIDResponse(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -318,7 +318,7 @@ public bool TryPickIncrementLedgerEntry([NotNullWhen(true)] out IncrementLedgerE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -339,7 +339,7 @@ public bool TryPickDecrementLedgerEntry([NotNullWhen(true)] out DecrementLedgerE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -362,7 +362,7 @@ public bool TryPickExpirationChangeLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -385,7 +385,7 @@ public bool TryPickCreditBlockExpiryLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -406,7 +406,7 @@ public bool TryPickVoidLedgerEntry([NotNullWhen(true)] out VoidLedgerEntry? valu /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -429,7 +429,7 @@ public bool TryPickVoidInitiatedLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -449,7 +449,7 @@ public bool TryPickAmendmentLedgerEntry([NotNullWhen(true)] out AmendmentLedgerE /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -460,13 +460,13 @@ public bool TryPickAmendmentLedgerEntry([NotNullWhen(true)] out AmendmentLedgerE /// /// /// instance.Switch( - /// (IncrementLedgerEntry value) => {...}, - /// (DecrementLedgerEntry value) => {...}, - /// (ExpirationChangeLedgerEntry value) => {...}, - /// (CreditBlockExpiryLedgerEntry value) => {...}, - /// (VoidLedgerEntry value) => {...}, - /// (VoidInitiatedLedgerEntry value) => {...}, - /// (AmendmentLedgerEntry value) => {...} + /// (IncrementLedgerEntry value) => {...}, + /// (DecrementLedgerEntry value) => {...}, + /// (ExpirationChangeLedgerEntry value) => {...}, + /// (CreditBlockExpiryLedgerEntry value) => {...}, + /// (VoidLedgerEntry value) => {...}, + /// (VoidInitiatedLedgerEntry value) => {...}, + /// (AmendmentLedgerEntry value) => {...} /// ); /// /// @@ -515,7 +515,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -526,13 +526,13 @@ public void Switch( /// /// /// var result = instance.Match( - /// (IncrementLedgerEntry value) => {...}, - /// (DecrementLedgerEntry value) => {...}, - /// (ExpirationChangeLedgerEntry value) => {...}, - /// (CreditBlockExpiryLedgerEntry value) => {...}, - /// (VoidLedgerEntry value) => {...}, - /// (VoidInitiatedLedgerEntry value) => {...}, - /// (AmendmentLedgerEntry value) => {...} + /// (IncrementLedgerEntry value) => {...}, + /// (DecrementLedgerEntry value) => {...}, + /// (ExpirationChangeLedgerEntry value) => {...}, + /// (CreditBlockExpiryLedgerEntry value) => {...}, + /// (VoidLedgerEntry value) => {...}, + /// (VoidInitiatedLedgerEntry value) => {...}, + /// (AmendmentLedgerEntry value) => {...} /// ); /// /// @@ -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 @@ -660,12 +678,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -682,12 +698,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -704,12 +718,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -726,12 +738,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -748,12 +758,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -770,12 +778,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -792,12 +798,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } 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..ddff956f6 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, @@ -223,24 +227,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] LedgerListParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static LedgerListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID + ); + } + + 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) @@ -262,6 +298,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..7e02c1afb 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListResponse.cs @@ -288,7 +288,7 @@ public LedgerListResponse(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -309,7 +309,7 @@ public bool TryPickIncrementLedgerEntry([NotNullWhen(true)] out IncrementLedgerE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -330,7 +330,7 @@ public bool TryPickDecrementLedgerEntry([NotNullWhen(true)] out DecrementLedgerE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -353,7 +353,7 @@ public bool TryPickExpirationChangeLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -376,7 +376,7 @@ public bool TryPickCreditBlockExpiryLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -397,7 +397,7 @@ public bool TryPickVoidLedgerEntry([NotNullWhen(true)] out VoidLedgerEntry? valu /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -420,7 +420,7 @@ public bool TryPickVoidInitiatedLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -440,7 +440,7 @@ public bool TryPickAmendmentLedgerEntry([NotNullWhen(true)] out AmendmentLedgerE /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -451,13 +451,13 @@ public bool TryPickAmendmentLedgerEntry([NotNullWhen(true)] out AmendmentLedgerE /// /// /// instance.Switch( - /// (IncrementLedgerEntry value) => {...}, - /// (DecrementLedgerEntry value) => {...}, - /// (ExpirationChangeLedgerEntry value) => {...}, - /// (CreditBlockExpiryLedgerEntry value) => {...}, - /// (VoidLedgerEntry value) => {...}, - /// (VoidInitiatedLedgerEntry value) => {...}, - /// (AmendmentLedgerEntry value) => {...} + /// (IncrementLedgerEntry value) => {...}, + /// (DecrementLedgerEntry value) => {...}, + /// (ExpirationChangeLedgerEntry value) => {...}, + /// (CreditBlockExpiryLedgerEntry value) => {...}, + /// (VoidLedgerEntry value) => {...}, + /// (VoidInitiatedLedgerEntry value) => {...}, + /// (AmendmentLedgerEntry value) => {...} /// ); /// /// @@ -506,7 +506,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -517,13 +517,13 @@ public void Switch( /// /// /// var result = instance.Match( - /// (IncrementLedgerEntry value) => {...}, - /// (DecrementLedgerEntry value) => {...}, - /// (ExpirationChangeLedgerEntry value) => {...}, - /// (CreditBlockExpiryLedgerEntry value) => {...}, - /// (VoidLedgerEntry value) => {...}, - /// (VoidInitiatedLedgerEntry value) => {...}, - /// (AmendmentLedgerEntry value) => {...} + /// (IncrementLedgerEntry value) => {...}, + /// (DecrementLedgerEntry value) => {...}, + /// (ExpirationChangeLedgerEntry value) => {...}, + /// (CreditBlockExpiryLedgerEntry value) => {...}, + /// (VoidLedgerEntry value) => {...}, + /// (VoidInitiatedLedgerEntry value) => {...}, + /// (AmendmentLedgerEntry value) => {...} /// ); /// /// @@ -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 @@ -644,12 +662,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -666,12 +682,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -688,12 +702,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -710,12 +722,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -732,12 +742,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -754,12 +762,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -776,12 +782,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } 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..f50792375 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, @@ -169,29 +176,68 @@ IReadOnlyDictionary rawBodyData TopUpCreateByExternalIDParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static TopUpCreateByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + externalCustomerID ); } + 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 +269,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -313,10 +364,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..8b07a3ef9 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, @@ -165,29 +172,63 @@ IReadOnlyDictionary rawBodyData TopUpCreateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static TopUpCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + customerID ); } + 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 +257,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -301,8 +347,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..5e57a66cf 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, @@ -42,24 +49,64 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] TopUpDeleteByExternalIDParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalCustomerID, + string topUpID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalCustomerID = externalCustomerID; + this.TopUpID = topUpID; } #pragma warning restore CS8618 - /// + /// public static TopUpDeleteByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalCustomerID, + string topUpID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalCustomerID, + topUpID + ); + } + + 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) @@ -85,4 +132,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..d2d2c0576 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, @@ -40,24 +47,62 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] TopUpDeleteParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID, + string topUpID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; + this.TopUpID = topUpID; } #pragma warning restore CS8618 - /// + /// public static TopUpDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID, + string topUpID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID, + topUpID + ); + } + + 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) @@ -79,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/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..c30ab15fd 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, @@ -71,24 +78,61 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] TopUpListByExternalIDParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static TopUpListByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalCustomerID + ); + } + + 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) @@ -113,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/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..290592e35 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, @@ -71,24 +78,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] TopUpListParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static TopUpListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID + ); + } + + 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) @@ -110,4 +149,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..b74b276bd 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) { @@ -603,6 +610,7 @@ public enum CustomerPaymentProvider StripeCharge, StripeInvoice, Netsuite, + NetsuiteAmpersand, } sealed class CustomerPaymentProviderConverter : JsonConverter @@ -620,6 +628,7 @@ JsonSerializerOptions options "stripe_charge" => CustomerPaymentProvider.StripeCharge, "stripe_invoice" => CustomerPaymentProvider.StripeInvoice, "netsuite" => CustomerPaymentProvider.Netsuite, + "netsuite_ampersand" => CustomerPaymentProvider.NetsuiteAmpersand, _ => (CustomerPaymentProvider)(-1), }; } @@ -639,6 +648,7 @@ JsonSerializerOptions options CustomerPaymentProvider.StripeCharge => "stripe_charge", CustomerPaymentProvider.StripeInvoice => "stripe_invoice", CustomerPaymentProvider.Netsuite => "netsuite", + CustomerPaymentProvider.NetsuiteAmpersand => "netsuite_ampersand", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -693,8 +703,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 +773,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) { @@ -797,6 +813,7 @@ public enum AccountingProviderProviderType { Quickbooks, Netsuite, + NetsuiteAmpersand, } sealed class AccountingProviderProviderTypeConverter : JsonConverter @@ -811,6 +828,7 @@ JsonSerializerOptions options { "quickbooks" => AccountingProviderProviderType.Quickbooks, "netsuite" => AccountingProviderProviderType.Netsuite, + "netsuite_ampersand" => AccountingProviderProviderType.NetsuiteAmpersand, _ => (AccountingProviderProviderType)(-1), }; } @@ -827,6 +845,7 @@ JsonSerializerOptions options { AccountingProviderProviderType.Quickbooks => "quickbooks", AccountingProviderProviderType.Netsuite => "netsuite", + AccountingProviderProviderType.NetsuiteAmpersand => "netsuite_ampersand", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -882,8 +901,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) { @@ -941,6 +963,21 @@ public required ApiEnum< init { this._rawData.Set("provider_type", value); } } + /// + /// The ID of a shared payment token granted by an agent to use as the default + /// payment instrument for this customer. When set, auto-collection will use + /// this token instead of the customer's default payment method. + /// + public string? DefaultSharedPaymentToken + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("default_shared_payment_token"); + } + init { this._rawData.Set("default_shared_payment_token", value); } + } + /// /// List of Stripe payment method types to exclude for this customer. Excluded /// payment methods will not be available for the customer to select during payment, @@ -975,15 +1012,19 @@ public IReadOnlyList? ExcludedPaymentMethodTypes public override void Validate() { this.ProviderType.Validate(); + _ = this.DefaultSharedPaymentToken; _ = this.ExcludedPaymentMethodTypes; } public CustomerPaymentConfigurationPaymentProvider() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerPaymentConfigurationPaymentProvider( CustomerPaymentConfigurationPaymentProvider customerPaymentConfigurationPaymentProvider ) : base(customerPaymentConfigurationPaymentProvider) { } +#pragma warning restore CS8618 public CustomerPaymentConfigurationPaymentProvider( IReadOnlyDictionary rawData @@ -1093,8 +1134,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..698879ff1 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, @@ -448,7 +456,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static CustomerCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -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 { /// @@ -584,6 +626,21 @@ public required ApiEnum ProviderType init { this._rawData.Set("provider_type", value); } } + /// + /// The ID of a shared payment token granted by an agent to use as the default + /// payment instrument for this customer. When set, auto-collection will use + /// this token instead of the customer's default payment method. + /// + public string? DefaultSharedPaymentToken + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("default_shared_payment_token"); + } + init { this._rawData.Set("default_shared_payment_token", value); } + } + /// /// List of Stripe payment method types to exclude for this customer. Excluded /// payment methods will not be available for the customer to select during payment, @@ -618,13 +675,17 @@ public IReadOnlyList? ExcludedPaymentMethodTypes public override void Validate() { this.ProviderType.Validate(); + _ = this.DefaultSharedPaymentToken; _ = this.ExcludedPaymentMethodTypes; } 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 +701,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 +714,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); } /// @@ -719,6 +777,7 @@ public enum CustomerCreateParamsPaymentProvider StripeCharge, StripeInvoice, Netsuite, + NetsuiteAmpersand, } sealed class CustomerCreateParamsPaymentProviderConverter @@ -737,6 +796,7 @@ JsonSerializerOptions options "stripe_charge" => CustomerCreateParamsPaymentProvider.StripeCharge, "stripe_invoice" => CustomerCreateParamsPaymentProvider.StripeInvoice, "netsuite" => CustomerCreateParamsPaymentProvider.Netsuite, + "netsuite_ampersand" => CustomerCreateParamsPaymentProvider.NetsuiteAmpersand, _ => (CustomerCreateParamsPaymentProvider)(-1), }; } @@ -756,6 +816,7 @@ JsonSerializerOptions options CustomerCreateParamsPaymentProvider.StripeCharge => "stripe_charge", CustomerCreateParamsPaymentProvider.StripeInvoice => "stripe_invoice", CustomerCreateParamsPaymentProvider.Netsuite => "netsuite", + CustomerCreateParamsPaymentProvider.NetsuiteAmpersand => "netsuite_ampersand", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -858,7 +919,7 @@ public TaxConfiguration(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -879,7 +940,7 @@ public bool TryPickNewAvalara([NotNullWhen(true)] out NewAvalaraTaxConfiguration /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -900,7 +961,7 @@ public bool TryPickNewTaxJar([NotNullWhen(true)] out NewTaxJarConfiguration? val /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -921,7 +982,7 @@ public bool TryPickNewSphere([NotNullWhen(true)] out NewSphereConfiguration? val /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -942,7 +1003,7 @@ public bool TryPickNumeral([NotNullWhen(true)] out Numeral? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -963,7 +1024,7 @@ public bool TryPickAnrok([NotNullWhen(true)] out Anrok? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -983,7 +1044,7 @@ public bool TryPickStripe([NotNullWhen(true)] out Stripe? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -994,12 +1055,12 @@ public bool TryPickStripe([NotNullWhen(true)] out Stripe? value) /// /// /// instance.Switch( - /// (NewAvalaraTaxConfiguration value) => {...}, - /// (NewTaxJarConfiguration value) => {...}, - /// (NewSphereConfiguration value) => {...}, - /// (Numeral value) => {...}, - /// (Anrok value) => {...}, - /// (Stripe value) => {...} + /// (NewAvalaraTaxConfiguration value) => {...}, + /// (NewTaxJarConfiguration value) => {...}, + /// (NewSphereConfiguration value) => {...}, + /// (Numeral value) => {...}, + /// (Anrok value) => {...}, + /// (Stripe value) => {...} /// ); /// /// @@ -1044,7 +1105,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1055,12 +1116,12 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewAvalaraTaxConfiguration value) => {...}, - /// (NewTaxJarConfiguration value) => {...}, - /// (NewSphereConfiguration value) => {...}, - /// (Numeral value) => {...}, - /// (Anrok value) => {...}, - /// (Stripe value) => {...} + /// (NewAvalaraTaxConfiguration value) => {...}, + /// (NewTaxJarConfiguration value) => {...}, + /// (NewSphereConfiguration value) => {...}, + /// (Numeral value) => {...}, + /// (Anrok value) => {...}, + /// (Stripe value) => {...} /// ); /// /// @@ -1127,10 +1188,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 +1199,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 @@ -1172,12 +1250,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1194,12 +1270,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1216,12 +1290,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1235,12 +1307,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1254,12 +1324,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1273,12 +1341,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1355,8 +1421,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 +1516,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 +1611,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..8cb4e6288 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, @@ -46,26 +53,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CustomerDeleteParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static CustomerDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID ); } + 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 +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/CustomerFetchByExternalIDParams.cs b/src/Orb/Models/Customers/CustomerFetchByExternalIDParams.cs index 567a20645..2f2842a1f 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, @@ -41,26 +48,63 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CustomerFetchByExternalIDParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static CustomerFetchByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalCustomerID ); } + 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 +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/CustomerFetchParams.cs b/src/Orb/Models/Customers/CustomerFetchParams.cs index df3020ce6..3933122d4 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, @@ -41,26 +48,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CustomerFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static CustomerFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID ); } + 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 +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/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..ff31d7dce 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, @@ -118,7 +125,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static CustomerListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -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..97d02ac07 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, @@ -45,24 +51,63 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalCustomerID + ); + } + + 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) @@ -87,4 +132,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..fd5f3d6b4 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, @@ -43,26 +50,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CustomerSyncPaymentMethodsFromGatewayParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static CustomerSyncPaymentMethodsFromGatewayParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID ); } + 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 +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/Customers/CustomerUpdateByExternalIDParams.cs b/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs index cdaab38bd..2bfe546a3 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, @@ -429,27 +438,61 @@ IReadOnlyDictionary rawBodyData CustomerUpdateByExternalIDParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string id ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ID = id; } #pragma warning restore CS8618 - /// + /// public static CustomerUpdateByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string id ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + id + ); + } + + 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) @@ -480,6 +523,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -531,10 +579,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 @@ -601,6 +652,21 @@ public required ApiEnum< init { this._rawData.Set("provider_type", value); } } + /// + /// The ID of a shared payment token granted by an agent to use as the default + /// payment instrument for this customer. When set, auto-collection will use + /// this token instead of the customer's default payment method. + /// + public string? DefaultSharedPaymentToken + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("default_shared_payment_token"); + } + init { this._rawData.Set("default_shared_payment_token", value); } + } + /// /// List of Stripe payment method types to exclude for this customer. Excluded /// payment methods will not be available for the customer to select during payment, @@ -635,15 +701,19 @@ public IReadOnlyList? ExcludedPaymentMethodTypes public override void Validate() { this.ProviderType.Validate(); + _ = this.DefaultSharedPaymentToken; _ = this.ExcludedPaymentMethodTypes; } public CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider( CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider customerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider ) : base(customerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider) { } +#pragma warning restore CS8618 public CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider( IReadOnlyDictionary rawData @@ -761,6 +831,7 @@ public enum CustomerUpdateByExternalIDParamsPaymentProvider StripeCharge, StripeInvoice, Netsuite, + NetsuiteAmpersand, } sealed class CustomerUpdateByExternalIDParamsPaymentProviderConverter @@ -779,6 +850,8 @@ JsonSerializerOptions options "stripe_charge" => CustomerUpdateByExternalIDParamsPaymentProvider.StripeCharge, "stripe_invoice" => CustomerUpdateByExternalIDParamsPaymentProvider.StripeInvoice, "netsuite" => CustomerUpdateByExternalIDParamsPaymentProvider.Netsuite, + "netsuite_ampersand" => + CustomerUpdateByExternalIDParamsPaymentProvider.NetsuiteAmpersand, _ => (CustomerUpdateByExternalIDParamsPaymentProvider)(-1), }; } @@ -798,6 +871,8 @@ JsonSerializerOptions options CustomerUpdateByExternalIDParamsPaymentProvider.StripeCharge => "stripe_charge", CustomerUpdateByExternalIDParamsPaymentProvider.StripeInvoice => "stripe_invoice", CustomerUpdateByExternalIDParamsPaymentProvider.Netsuite => "netsuite", + CustomerUpdateByExternalIDParamsPaymentProvider.NetsuiteAmpersand => + "netsuite_ampersand", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -918,7 +993,7 @@ public CustomerUpdateByExternalIDParamsTaxConfiguration(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -939,7 +1014,7 @@ public bool TryPickNewAvalara([NotNullWhen(true)] out NewAvalaraTaxConfiguration /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -960,7 +1035,7 @@ public bool TryPickNewTaxJar([NotNullWhen(true)] out NewTaxJarConfiguration? val /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -981,7 +1056,7 @@ public bool TryPickNewSphere([NotNullWhen(true)] out NewSphereConfiguration? val /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1004,7 +1079,7 @@ public bool TryPickNumeral( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1027,7 +1102,7 @@ public bool TryPickAnrok( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1049,7 +1124,7 @@ public bool TryPickStripe( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1060,12 +1135,12 @@ public bool TryPickStripe( /// /// /// instance.Switch( - /// (NewAvalaraTaxConfiguration value) => {...}, - /// (NewTaxJarConfiguration value) => {...}, - /// (NewSphereConfiguration value) => {...}, - /// (CustomerUpdateByExternalIDParamsTaxConfigurationNumeral value) => {...}, - /// (CustomerUpdateByExternalIDParamsTaxConfigurationAnrok value) => {...}, - /// (CustomerUpdateByExternalIDParamsTaxConfigurationStripe value) => {...} + /// (NewAvalaraTaxConfiguration value) => {...}, + /// (NewTaxJarConfiguration value) => {...}, + /// (NewSphereConfiguration value) => {...}, + /// (CustomerUpdateByExternalIDParamsTaxConfigurationNumeral value) => {...}, + /// (CustomerUpdateByExternalIDParamsTaxConfigurationAnrok value) => {...}, + /// (CustomerUpdateByExternalIDParamsTaxConfigurationStripe value) => {...} /// ); /// /// @@ -1110,7 +1185,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1121,12 +1196,12 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewAvalaraTaxConfiguration value) => {...}, - /// (NewTaxJarConfiguration value) => {...}, - /// (NewSphereConfiguration value) => {...}, - /// (CustomerUpdateByExternalIDParamsTaxConfigurationNumeral value) => {...}, - /// (CustomerUpdateByExternalIDParamsTaxConfigurationAnrok value) => {...}, - /// (CustomerUpdateByExternalIDParamsTaxConfigurationStripe value) => {...} + /// (NewAvalaraTaxConfiguration value) => {...}, + /// (NewTaxJarConfiguration value) => {...}, + /// (NewSphereConfiguration value) => {...}, + /// (CustomerUpdateByExternalIDParamsTaxConfigurationNumeral value) => {...}, + /// (CustomerUpdateByExternalIDParamsTaxConfigurationAnrok value) => {...}, + /// (CustomerUpdateByExternalIDParamsTaxConfigurationStripe value) => {...} /// ); /// /// @@ -1206,10 +1281,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 +1292,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 @@ -1252,12 +1344,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1274,12 +1364,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1296,12 +1384,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1319,12 +1405,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1342,12 +1426,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1365,12 +1447,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1452,10 +1532,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 +1642,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 +1752,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..8229c480a 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, @@ -428,27 +438,61 @@ IReadOnlyDictionary rawBodyData CustomerUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static CustomerUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + customerID + ); + } + + 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) @@ -479,6 +523,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -530,10 +579,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 @@ -594,6 +646,21 @@ public required ApiEnum< init { this._rawData.Set("provider_type", value); } } + /// + /// The ID of a shared payment token granted by an agent to use as the default + /// payment instrument for this customer. When set, auto-collection will use + /// this token instead of the customer's default payment method. + /// + public string? DefaultSharedPaymentToken + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("default_shared_payment_token"); + } + init { this._rawData.Set("default_shared_payment_token", value); } + } + /// /// List of Stripe payment method types to exclude for this customer. Excluded /// payment methods will not be available for the customer to select during payment, @@ -628,15 +695,19 @@ public IReadOnlyList? ExcludedPaymentMethodTypes public override void Validate() { this.ProviderType.Validate(); + _ = this.DefaultSharedPaymentToken; _ = this.ExcludedPaymentMethodTypes; } public CustomerUpdateParamsPaymentConfigurationPaymentProvider() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateParamsPaymentConfigurationPaymentProvider( CustomerUpdateParamsPaymentConfigurationPaymentProvider customerUpdateParamsPaymentConfigurationPaymentProvider ) : base(customerUpdateParamsPaymentConfigurationPaymentProvider) { } +#pragma warning restore CS8618 public CustomerUpdateParamsPaymentConfigurationPaymentProvider( IReadOnlyDictionary rawData @@ -748,6 +819,7 @@ public enum CustomerUpdateParamsPaymentProvider StripeCharge, StripeInvoice, Netsuite, + NetsuiteAmpersand, } sealed class CustomerUpdateParamsPaymentProviderConverter @@ -766,6 +838,7 @@ JsonSerializerOptions options "stripe_charge" => CustomerUpdateParamsPaymentProvider.StripeCharge, "stripe_invoice" => CustomerUpdateParamsPaymentProvider.StripeInvoice, "netsuite" => CustomerUpdateParamsPaymentProvider.Netsuite, + "netsuite_ampersand" => CustomerUpdateParamsPaymentProvider.NetsuiteAmpersand, _ => (CustomerUpdateParamsPaymentProvider)(-1), }; } @@ -785,6 +858,7 @@ JsonSerializerOptions options CustomerUpdateParamsPaymentProvider.StripeCharge => "stripe_charge", CustomerUpdateParamsPaymentProvider.StripeInvoice => "stripe_invoice", CustomerUpdateParamsPaymentProvider.Netsuite => "netsuite", + CustomerUpdateParamsPaymentProvider.NetsuiteAmpersand => "netsuite_ampersand", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -905,7 +979,7 @@ public CustomerUpdateParamsTaxConfiguration(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -926,7 +1000,7 @@ public bool TryPickNewAvalara([NotNullWhen(true)] out NewAvalaraTaxConfiguration /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -947,7 +1021,7 @@ public bool TryPickNewTaxJar([NotNullWhen(true)] out NewTaxJarConfiguration? val /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -968,7 +1042,7 @@ public bool TryPickNewSphere([NotNullWhen(true)] out NewSphereConfiguration? val /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -991,7 +1065,7 @@ public bool TryPickNumeral( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1014,7 +1088,7 @@ public bool TryPickAnrok( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1036,7 +1110,7 @@ public bool TryPickStripe( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1047,12 +1121,12 @@ public bool TryPickStripe( /// /// /// instance.Switch( - /// (NewAvalaraTaxConfiguration value) => {...}, - /// (NewTaxJarConfiguration value) => {...}, - /// (NewSphereConfiguration value) => {...}, - /// (CustomerUpdateParamsTaxConfigurationNumeral value) => {...}, - /// (CustomerUpdateParamsTaxConfigurationAnrok value) => {...}, - /// (CustomerUpdateParamsTaxConfigurationStripe value) => {...} + /// (NewAvalaraTaxConfiguration value) => {...}, + /// (NewTaxJarConfiguration value) => {...}, + /// (NewSphereConfiguration value) => {...}, + /// (CustomerUpdateParamsTaxConfigurationNumeral value) => {...}, + /// (CustomerUpdateParamsTaxConfigurationAnrok value) => {...}, + /// (CustomerUpdateParamsTaxConfigurationStripe value) => {...} /// ); /// /// @@ -1097,7 +1171,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1108,12 +1182,12 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewAvalaraTaxConfiguration value) => {...}, - /// (NewTaxJarConfiguration value) => {...}, - /// (NewSphereConfiguration value) => {...}, - /// (CustomerUpdateParamsTaxConfigurationNumeral value) => {...}, - /// (CustomerUpdateParamsTaxConfigurationAnrok value) => {...}, - /// (CustomerUpdateParamsTaxConfigurationStripe value) => {...} + /// (NewAvalaraTaxConfiguration value) => {...}, + /// (NewTaxJarConfiguration value) => {...}, + /// (NewSphereConfiguration value) => {...}, + /// (CustomerUpdateParamsTaxConfigurationNumeral value) => {...}, + /// (CustomerUpdateParamsTaxConfigurationAnrok value) => {...}, + /// (CustomerUpdateParamsTaxConfigurationStripe value) => {...} /// ); /// /// @@ -1193,10 +1267,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 +1278,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 @@ -1239,12 +1330,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1261,12 +1350,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1283,12 +1370,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1306,12 +1391,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1329,12 +1412,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1352,12 +1433,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1439,10 +1518,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 +1626,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 +1734,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..b02c9d9ab 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, @@ -137,7 +144,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static DimensionalPriceGroupCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -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..e7ea86042 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, @@ -76,7 +83,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static DimensionalPriceGroupListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -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..b6ed95ccf 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, @@ -38,24 +45,61 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] DimensionalPriceGroupRetrieveParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string dimensionalPriceGroupID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.DimensionalPriceGroupID = dimensionalPriceGroupID; } #pragma warning restore CS8618 - /// + /// public static DimensionalPriceGroupRetrieveParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string dimensionalPriceGroupID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + dimensionalPriceGroupID + ); + } + + 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) @@ -77,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/DimensionalPriceGroupUpdateParams.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParams.cs index 14f6f05e1..dbcc9d2ba 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, @@ -93,27 +100,66 @@ IReadOnlyDictionary rawBodyData DimensionalPriceGroupUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string dimensionalPriceGroupID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.DimensionalPriceGroupID = dimensionalPriceGroupID; } #pragma warning restore CS8618 - /// + /// public static DimensionalPriceGroupUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string dimensionalPriceGroupID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + dimensionalPriceGroupID + ); + } + + 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) @@ -144,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/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParams.cs b/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParams.cs index abd46f11f..0aaaa8c01 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, @@ -39,24 +46,61 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] ExternalDimensionalPriceGroupIDRetrieveParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalDimensionalPriceGroupID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalDimensionalPriceGroupID = externalDimensionalPriceGroupID; } #pragma warning restore CS8618 - /// + /// public static ExternalDimensionalPriceGroupIDRetrieveParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalDimensionalPriceGroupID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalDimensionalPriceGroupID + ); + } + + 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) @@ -81,4 +125,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..1478b3658 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, @@ -94,27 +101,66 @@ IReadOnlyDictionary rawBodyData ExternalDimensionalPriceGroupIDUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string externalDimensionalPriceGroupID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ExternalDimensionalPriceGroupID = externalDimensionalPriceGroupID; } #pragma warning restore CS8618 - /// + /// public static ExternalDimensionalPriceGroupIDUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string externalDimensionalPriceGroupID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + externalDimensionalPriceGroupID + ); + } + + 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) @@ -148,4 +194,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..11a0f60e1 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, @@ -39,24 +46,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] BackfillCloseParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string backfillID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.BackfillID = backfillID; } #pragma warning restore CS8618 - /// + /// public static BackfillCloseParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string backfillID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + backfillID + ); + } + + 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) @@ -78,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/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..2aea9f90e 100644 --- a/src/Orb/Models/Events/Backfills/BackfillCreateParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillCreateParams.cs @@ -14,8 +14,8 @@ namespace Orb.Models.Events.Backfills; /// are older than the ingestion grace period. Performing a backfill in Orb involves /// 3 steps: /// -/// 1. Create the backfill, specifying its parameters. 2. [Ingest](ingest) usage -/// events, referencing the backfill (query parameter `backfill_id`). 3. [Close](close-backfill) +/// 1. Create the backfill, specifying its parameters. 2. [Ingest](/api-reference/event/ingest-events) +/// usage events, referencing the backfill (query parameter `backfill_id`). 3. [Close](close-backfill) /// the backfill, propagating the update in past usage throughout Orb. /// /// Changes from a backfill are not reflected until the backfill is closed, @@ -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, @@ -196,7 +203,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static BackfillCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -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..f05dba004 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, @@ -36,24 +43,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] BackfillFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string backfillID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.BackfillID = backfillID; } #pragma warning restore CS8618 - /// + /// public static BackfillFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string backfillID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + backfillID + ); + } + + 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) @@ -75,4 +114,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/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..42ed34f64 100644 --- a/src/Orb/Models/Events/Backfills/BackfillListParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillListParams.cs @@ -13,10 +13,13 @@ namespace Orb.Models.Events.Backfills; /// /// The list of backfills is ordered starting from the most recently created /// 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). +/// 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 BackfillListParams : ParamsBase +public record class BackfillListParams : ParamsBase { /// /// Cursor for pagination. This can be populated by the `next_cursor` value returned @@ -55,8 +58,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, @@ -79,7 +85,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static BackfillListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -91,6 +97,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 +139,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/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..490e4387a 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, @@ -42,26 +49,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] BackfillRevertParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string backfillID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.BackfillID = backfillID; } #pragma warning restore CS8618 - /// + /// public static BackfillRevertParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string backfillID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + backfillID ); } + 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 +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/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..20f852c92 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, @@ -68,26 +75,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] EventDeprecateParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string eventID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.EventID = eventID; } #pragma warning restore CS8618 - /// + /// public static EventDeprecateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string eventID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + eventID ); } + 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 +146,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..e873a737b 100644 --- a/src/Orb/Models/Events/EventIngestParams.cs +++ b/src/Orb/Models/Events/EventIngestParams.cs @@ -62,7 +62,7 @@ namespace Orb.Models.Events; /// collide). - The `timestamp` field in the event body will be used to determine /// which billable period a given event falls into. For example, with a monthly billing /// cycle starting from the first of December, Orb will calculate metrics based on -/// events that fall into the range `12-01 00:00:00 <= timestamp < 01-01 00:00:00`. +/// events that fall into the range `12-01 00:00:00 <= timestamp < 01-01 00:00:00`. /// /// ## Logging metadata /// @@ -97,10 +97,10 @@ namespace Orb.Models.Events; /// /// In cases where usage is reported in aggregate for a historical timeframe, /// the timestamp must be within the grace period set for your account. Events with -/// `timestamp < current_time - grace_period` will not be accepted as a valid event, -/// and will throw validation errors. Enforcing the grace period enables Orb to accurately -/// map usage to the correct billing cycle and ensure that all usage is billed for -/// in the corresponding billing period. +/// `timestamp < current_time - grace_period` will not be accepted as a valid +/// event, and will throw validation errors. Enforcing the grace period enables Orb +/// to accurately map usage to the correct billing cycle and ensure that all usage +/// is billed for in the corresponding billing period. /// /// In general, Orb does not expect events with future dated timestamps. In /// cases where the timestamp is at least 24 hours ahead of the current time, the @@ -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, @@ -268,7 +275,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static EventIngestParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -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..d79f47f4f 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, @@ -117,7 +124,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static EventSearchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -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..6096c9e65 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, @@ -161,29 +168,63 @@ IReadOnlyDictionary rawBodyData EventUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string eventID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.EventID = eventID; } #pragma warning restore CS8618 - /// + /// public static EventUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string eventID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + eventID ); } + 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 +252,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..6338349a3 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, @@ -123,7 +130,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static VolumeListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -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..ba904a797 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) { @@ -1394,8 +1407,8 @@ public required string AdjustedSubtotal /// /// All adjustments applied to the line item in the order they were applied based - /// on invoice calculations (ie. usage discounts -> amount discounts -> percentage - /// discounts -> minimums -> maximums). + /// on invoice calculations (ie. usage discounts -> amount discounts -> + /// percentage discounts -> minimums -> maximums). /// public required IReadOnlyList Adjustments { @@ -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) { @@ -1829,7 +1845,7 @@ public InvoiceLineItemAdjustment(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1852,7 +1868,7 @@ public bool TryPickMonetaryUsageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1875,7 +1891,7 @@ public bool TryPickMonetaryAmountDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1898,7 +1914,7 @@ public bool TryPickMonetaryPercentageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1919,7 +1935,7 @@ public bool TryPickMonetaryMinimum([NotNullWhen(true)] out MonetaryMinimumAdjust /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1939,7 +1955,7 @@ public bool TryPickMonetaryMaximum([NotNullWhen(true)] out MonetaryMaximumAdjust /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1950,11 +1966,11 @@ public bool TryPickMonetaryMaximum([NotNullWhen(true)] out MonetaryMaximumAdjust /// /// /// instance.Switch( - /// (MonetaryUsageDiscountAdjustment value) => {...}, - /// (MonetaryAmountDiscountAdjustment value) => {...}, - /// (MonetaryPercentageDiscountAdjustment value) => {...}, - /// (MonetaryMinimumAdjustment value) => {...}, - /// (MonetaryMaximumAdjustment value) => {...} + /// (MonetaryUsageDiscountAdjustment value) => {...}, + /// (MonetaryAmountDiscountAdjustment value) => {...}, + /// (MonetaryPercentageDiscountAdjustment value) => {...}, + /// (MonetaryMinimumAdjustment value) => {...}, + /// (MonetaryMaximumAdjustment value) => {...} /// ); /// /// @@ -1995,7 +2011,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2006,11 +2022,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MonetaryUsageDiscountAdjustment value) => {...}, - /// (MonetaryAmountDiscountAdjustment value) => {...}, - /// (MonetaryPercentageDiscountAdjustment value) => {...}, - /// (MonetaryMinimumAdjustment value) => {...}, - /// (MonetaryMaximumAdjustment value) => {...} + /// (MonetaryUsageDiscountAdjustment value) => {...}, + /// (MonetaryAmountDiscountAdjustment value) => {...}, + /// (MonetaryPercentageDiscountAdjustment value) => {...}, + /// (MonetaryMinimumAdjustment value) => {...}, + /// (MonetaryMaximumAdjustment value) => {...} /// ); /// /// @@ -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 @@ -2126,12 +2158,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2148,12 +2178,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2171,12 +2199,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2193,12 +2219,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2215,12 +2239,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2326,7 +2348,7 @@ public InvoiceLineItemSubLineItem(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2347,7 +2369,7 @@ public bool TryPickMatrix([NotNullWhen(true)] out MatrixSubLineItem? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2368,7 +2390,7 @@ public bool TryPickTier([NotNullWhen(true)] out TierSubLineItem? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2388,7 +2410,7 @@ public bool TryPickOther([NotNullWhen(true)] out OtherSubLineItem? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2399,9 +2421,9 @@ public bool TryPickOther([NotNullWhen(true)] out OtherSubLineItem? value) /// /// /// instance.Switch( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -2434,7 +2456,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2445,9 +2467,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -2502,10 +2524,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 +2535,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 @@ -2547,12 +2583,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2569,12 +2603,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2591,12 +2623,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2731,8 +2761,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..dbc4afc0e 100644 --- a/src/Orb/Models/InvoiceLevelDiscount.cs +++ b/src/Orb/Models/InvoiceLevelDiscount.cs @@ -64,7 +64,7 @@ public InvoiceLevelDiscount(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -85,7 +85,7 @@ public bool TryPickPercentage([NotNullWhen(true)] out PercentageDiscount? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -106,7 +106,7 @@ public bool TryPickAmount([NotNullWhen(true)] out AmountDiscount? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -126,7 +126,7 @@ public bool TryPickTrial([NotNullWhen(true)] out TrialDiscount? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -137,9 +137,9 @@ public bool TryPickTrial([NotNullWhen(true)] out TrialDiscount? value) /// /// /// instance.Switch( - /// (PercentageDiscount value) => {...}, - /// (AmountDiscount value) => {...}, - /// (TrialDiscount value) => {...} + /// (PercentageDiscount value) => {...}, + /// (AmountDiscount value) => {...}, + /// (TrialDiscount value) => {...} /// ); /// /// @@ -172,7 +172,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -183,9 +183,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (PercentageDiscount value) => {...}, - /// (AmountDiscount value) => {...}, - /// (TrialDiscount value) => {...} + /// (PercentageDiscount value) => {...}, + /// (AmountDiscount value) => {...}, + /// (TrialDiscount value) => {...} /// ); /// /// @@ -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 @@ -283,12 +297,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -302,12 +314,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -321,12 +331,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateParams.cs b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateParams.cs index 2604e2c94..9be798411 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, @@ -162,7 +169,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static InvoiceLineItemCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -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..77459b3b2 100644 --- a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs +++ b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs @@ -44,21 +44,19 @@ public required string AdjustedSubtotal /// /// All adjustments applied to the line item in the order they were applied based - /// on invoice calculations (ie. usage discounts -> amount discounts -> percentage - /// discounts -> minimums -> maximums). + /// 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; @@ -475,7 +474,7 @@ public Adjustment(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -498,7 +497,7 @@ public bool TryPickMonetaryUsageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -521,7 +520,7 @@ public bool TryPickMonetaryAmountDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -544,7 +543,7 @@ public bool TryPickMonetaryPercentageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -565,7 +564,7 @@ public bool TryPickMonetaryMinimum([NotNullWhen(true)] out MonetaryMinimumAdjust /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -585,7 +584,7 @@ public bool TryPickMonetaryMaximum([NotNullWhen(true)] out MonetaryMaximumAdjust /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -596,11 +595,11 @@ public bool TryPickMonetaryMaximum([NotNullWhen(true)] out MonetaryMaximumAdjust /// /// /// instance.Switch( - /// (MonetaryUsageDiscountAdjustment value) => {...}, - /// (MonetaryAmountDiscountAdjustment value) => {...}, - /// (MonetaryPercentageDiscountAdjustment value) => {...}, - /// (MonetaryMinimumAdjustment value) => {...}, - /// (MonetaryMaximumAdjustment value) => {...} + /// (MonetaryUsageDiscountAdjustment value) => {...}, + /// (MonetaryAmountDiscountAdjustment value) => {...}, + /// (MonetaryPercentageDiscountAdjustment value) => {...}, + /// (MonetaryMinimumAdjustment value) => {...}, + /// (MonetaryMaximumAdjustment value) => {...} /// ); /// /// @@ -639,7 +638,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -650,11 +649,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MonetaryUsageDiscountAdjustment value) => {...}, - /// (MonetaryAmountDiscountAdjustment value) => {...}, - /// (MonetaryPercentageDiscountAdjustment value) => {...}, - /// (MonetaryMinimumAdjustment value) => {...}, - /// (MonetaryMaximumAdjustment value) => {...} + /// (MonetaryUsageDiscountAdjustment value) => {...}, + /// (MonetaryAmountDiscountAdjustment value) => {...}, + /// (MonetaryPercentageDiscountAdjustment value) => {...}, + /// (MonetaryMinimumAdjustment value) => {...}, + /// (MonetaryMaximumAdjustment value) => {...} /// ); /// /// @@ -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 @@ -768,12 +775,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -790,12 +795,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -813,12 +816,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -835,12 +836,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -857,12 +856,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -871,14 +868,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 +883,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.InvoiceLineItems.SubLineItemConverter))] +[JsonConverter(typeof(SubLineItemConverter))] public record class SubLineItem : ModelBase { public object? Value { get; } = null; @@ -968,7 +965,7 @@ public SubLineItem(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -989,7 +986,7 @@ public bool TryPickMatrix([NotNullWhen(true)] out MatrixSubLineItem? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1010,7 +1007,7 @@ public bool TryPickTier([NotNullWhen(true)] out TierSubLineItem? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1030,7 +1027,7 @@ public bool TryPickOther([NotNullWhen(true)] out OtherSubLineItem? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1041,9 +1038,9 @@ public bool TryPickOther([NotNullWhen(true)] out OtherSubLineItem? value) /// /// /// instance.Switch( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -1074,7 +1071,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1085,9 +1082,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -1107,17 +1104,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 +1133,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 +1144,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 @@ -1187,12 +1192,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1209,12 +1212,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1231,12 +1232,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1245,14 +1244,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..a0172b0b2 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, @@ -235,7 +255,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static InvoiceCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -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)) ), @@ -502,7 +548,7 @@ public DueDate(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -523,7 +569,7 @@ public bool TryPickDate([NotNullWhen(true)] out string? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -543,7 +589,7 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -554,8 +600,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -582,7 +628,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -593,8 +639,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset 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..aa866c7da 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, @@ -42,26 +49,64 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] InvoiceDeleteLineItemParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string invoiceID, + string lineItemID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.InvoiceID = invoiceID; + this.LineItemID = lineItemID; } #pragma warning restore CS8618 - /// + /// public static InvoiceDeleteLineItemParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string invoiceID, + string lineItemID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + invoiceID, + lineItemID ); } + 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 +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/Invoices/InvoiceFetchParams.cs b/src/Orb/Models/Invoices/InvoiceFetchParams.cs index 563df22da..a0007db76 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, @@ -36,24 +43,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] InvoiceFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string invoiceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.InvoiceID = invoiceID; } #pragma warning restore CS8618 - /// + /// public static InvoiceFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string invoiceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + invoiceID + ); + } + + 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) @@ -74,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/Invoices/InvoiceFetchUpcomingParams.cs b/src/Orb/Models/Invoices/InvoiceFetchUpcomingParams.cs index 193ec1bf6..18ea5fc57 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, @@ -50,7 +57,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static InvoiceFetchUpcomingParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -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..c0e1f588f 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)) ), @@ -1409,21 +1388,19 @@ public required string AdjustedSubtotal /// /// All adjustments applied to the line item in the order they were applied based - /// on invoice calculations (ie. usage discounts -> amount discounts -> percentage - /// discounts -> minimums -> maximums). + /// 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; @@ -1841,7 +1819,7 @@ public Adjustment(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1864,7 +1842,7 @@ public bool TryPickMonetaryUsageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1887,7 +1865,7 @@ public bool TryPickMonetaryAmountDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1910,7 +1888,7 @@ public bool TryPickMonetaryPercentageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1931,7 +1909,7 @@ public bool TryPickMonetaryMinimum([NotNullWhen(true)] out MonetaryMinimumAdjust /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1951,7 +1929,7 @@ public bool TryPickMonetaryMaximum([NotNullWhen(true)] out MonetaryMaximumAdjust /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1962,11 +1940,11 @@ public bool TryPickMonetaryMaximum([NotNullWhen(true)] out MonetaryMaximumAdjust /// /// /// instance.Switch( - /// (MonetaryUsageDiscountAdjustment value) => {...}, - /// (MonetaryAmountDiscountAdjustment value) => {...}, - /// (MonetaryPercentageDiscountAdjustment value) => {...}, - /// (MonetaryMinimumAdjustment value) => {...}, - /// (MonetaryMaximumAdjustment value) => {...} + /// (MonetaryUsageDiscountAdjustment value) => {...}, + /// (MonetaryAmountDiscountAdjustment value) => {...}, + /// (MonetaryPercentageDiscountAdjustment value) => {...}, + /// (MonetaryMinimumAdjustment value) => {...}, + /// (MonetaryMaximumAdjustment value) => {...} /// ); /// /// @@ -2005,7 +1983,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2016,11 +1994,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MonetaryUsageDiscountAdjustment value) => {...}, - /// (MonetaryAmountDiscountAdjustment value) => {...}, - /// (MonetaryPercentageDiscountAdjustment value) => {...}, - /// (MonetaryMinimumAdjustment value) => {...}, - /// (MonetaryMaximumAdjustment value) => {...} + /// (MonetaryUsageDiscountAdjustment value) => {...}, + /// (MonetaryAmountDiscountAdjustment value) => {...}, + /// (MonetaryPercentageDiscountAdjustment value) => {...}, + /// (MonetaryMinimumAdjustment value) => {...}, + /// (MonetaryMaximumAdjustment value) => {...} /// ); /// /// @@ -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 @@ -2134,12 +2120,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2156,12 +2140,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2179,12 +2161,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2201,12 +2181,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2223,12 +2201,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2237,14 +2213,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 +2228,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Invoices.SubLineItemConverter))] +[JsonConverter(typeof(SubLineItemConverter))] public record class SubLineItem : ModelBase { public object? Value { get; } = null; @@ -2334,7 +2310,7 @@ public SubLineItem(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2355,7 +2331,7 @@ public bool TryPickMatrix([NotNullWhen(true)] out MatrixSubLineItem? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2376,7 +2352,7 @@ public bool TryPickTier([NotNullWhen(true)] out TierSubLineItem? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2396,7 +2372,7 @@ public bool TryPickOther([NotNullWhen(true)] out OtherSubLineItem? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2407,9 +2383,9 @@ public bool TryPickOther([NotNullWhen(true)] out OtherSubLineItem? value) /// /// /// instance.Switch( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -2440,7 +2416,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2451,9 +2427,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -2473,17 +2449,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 +2478,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 +2489,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 @@ -2553,12 +2537,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2575,12 +2557,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2597,12 +2577,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2611,14 +2589,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 +2604,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 +2649,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 +2715,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 +2734,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 +2767,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 +2782,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..be154b13b 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, @@ -77,27 +84,61 @@ IReadOnlyDictionary rawBodyData InvoiceIssueParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string invoiceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.InvoiceID = invoiceID; } #pragma warning restore CS8618 - /// + /// public static InvoiceIssueParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string invoiceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + invoiceID + ); + } + + 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) @@ -128,4 +169,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..ca64493be --- /dev/null +++ b/src/Orb/Models/Invoices/InvoiceIssueSummaryParams.cs @@ -0,0 +1,180 @@ +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, + string invoiceID + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + this.InvoiceID = invoiceID; + } +#pragma warning restore CS8618 + + /// + public static InvoiceIssueSummaryParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData, + string invoiceID + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData), + invoiceID + ); + } + + 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..7b6e9b2f5 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, @@ -275,7 +283,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static InvoiceListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -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..0d498d536 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, @@ -293,7 +281,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static InvoiceListSummaryParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -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..f4c87be27 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, @@ -88,27 +95,61 @@ IReadOnlyDictionary rawBodyData InvoiceMarkPaidParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string invoiceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.InvoiceID = invoiceID; } #pragma warning restore CS8618 - /// + /// public static InvoiceMarkPaidParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string invoiceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + invoiceID + ); + } + + 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) @@ -139,4 +180,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Invoices/InvoicePayParams.cs b/src/Orb/Models/Invoices/InvoicePayParams.cs index 58694581e..ab1e1d45e 100644 --- a/src/Orb/Models/Invoices/InvoicePayParams.cs +++ b/src/Orb/Models/Invoices/InvoicePayParams.cs @@ -3,58 +3,129 @@ 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 collects payment for an invoice using the customer's default payment -/// method. This action can only be taken on invoices with status "issued". +/// This endpoint collects payment for an invoice. By default, it uses the customer's +/// default payment method. Optionally, a shared payment token (SPT) can be provided +/// to pay using agent-granted credentials instead. 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 { + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + public string? InvoiceID { get; init; } + /// + /// The ID of a shared payment token granted by an agent to use for this payment. + /// + public required string SharedPaymentTokenID + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("shared_payment_token_id"); + } + init { this._rawBodyData.Set("shared_payment_token_id", value); } + } + public InvoicePayParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoicePayParams(InvoicePayParams invoicePayParams) : base(invoicePayParams) { this.InvoiceID = invoicePayParams.InvoiceID; + + this._rawBodyData = new(invoicePayParams._rawBodyData); } +#pragma warning restore CS8618 public InvoicePayParams( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); } #pragma warning disable CS8618 [SetsRequiredMembers] InvoicePayParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData, + string invoiceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + this.InvoiceID = invoiceID; } #pragma warning restore CS8618 - /// + /// public static InvoicePayParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData, + string invoiceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData), + invoiceID + ); + } + + 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(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) + && this._rawBodyData.Equals(other._rawBodyData); } public override Uri Url(ClientOptions options) @@ -68,6 +139,15 @@ public override Uri Url(ClientOptions 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); @@ -76,4 +156,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Invoices/InvoiceUpdateParams.cs b/src/Orb/Models/Invoices/InvoiceUpdateParams.cs index f5727977b..192046e25 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, @@ -124,27 +146,61 @@ IReadOnlyDictionary rawBodyData InvoiceUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string invoiceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.InvoiceID = invoiceID; } #pragma warning restore CS8618 - /// + /// public static InvoiceUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string invoiceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + invoiceID + ); + } + + 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) @@ -174,6 +230,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -219,7 +280,7 @@ public InvoiceUpdateParamsDueDate(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -240,7 +301,7 @@ public bool TryPickDate([NotNullWhen(true)] out string? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -260,7 +321,7 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -271,8 +332,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -301,7 +362,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -312,8 +373,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -358,10 +419,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 +430,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 +470,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) { @@ -458,7 +535,7 @@ public InvoiceDate(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -479,7 +556,7 @@ public bool TryPickDate([NotNullWhen(true)] out string? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -499,7 +576,7 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -510,8 +587,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -538,7 +615,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -549,8 +626,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -590,10 +667,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 +678,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 +718,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..376a434ba 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, @@ -46,26 +53,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] InvoiceVoidParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string invoiceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.InvoiceID = invoiceID; } #pragma warning restore CS8618 - /// + /// public static InvoiceVoidParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string invoiceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + invoiceID ); } + 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 +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/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..9e1cf62e9 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, @@ -36,24 +43,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] ItemArchiveParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string itemID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ItemID = itemID; } #pragma warning restore CS8618 - /// + /// public static ItemArchiveParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string itemID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + itemID + ); + } + + 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) @@ -75,4 +114,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Items/ItemCreateParams.cs b/src/Orb/Models/Items/ItemCreateParams.cs index 53f156719..6a7d6a7ae 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, @@ -89,7 +96,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static ItemCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -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..07bfafbd4 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, @@ -36,24 +43,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] ItemFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string itemID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ItemID = itemID; } #pragma warning restore CS8618 - /// + /// public static ItemFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string itemID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + itemID + ); + } + + 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) @@ -74,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/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..574d47a42 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, @@ -74,7 +81,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static ItemListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -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..ff9e0e425 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, @@ -102,29 +109,63 @@ IReadOnlyDictionary rawBodyData ItemUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string itemID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ItemID = itemID; } #pragma warning restore CS8618 - /// + /// public static ItemUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string itemID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + itemID ); } + 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 +193,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -198,8 +244,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 +293,7 @@ public enum ExternalConnectionName Avalara, Anrok, Numeral, + StripeTax, } sealed class ExternalConnectionNameConverter : JsonConverter @@ -264,6 +314,7 @@ JsonSerializerOptions options "avalara" => ExternalConnectionName.Avalara, "anrok" => ExternalConnectionName.Anrok, "numeral" => ExternalConnectionName.Numeral, + "stripe_tax" => ExternalConnectionName.StripeTax, _ => (ExternalConnectionName)(-1), }; } @@ -286,6 +337,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..ceb0d6b45 --- /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..9db9494fc --- /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..aae4a47a9 --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveParams.cs @@ -0,0 +1,125 @@ +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, + string licenseTypeID + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this.LicenseTypeID = licenseTypeID; + } +#pragma warning restore CS8618 + + /// + public static LicenseTypeRetrieveParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + string licenseTypeID + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + licenseTypeID + ); + } + + 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..2eaec4c0c --- /dev/null +++ b/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParams.cs @@ -0,0 +1,240 @@ +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, + string externalLicenseID + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this.ExternalLicenseID = externalLicenseID; + } +#pragma warning restore CS8618 + + /// + public static ExternalLicenseGetUsageParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + string externalLicenseID + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalLicenseID + ); + } + + 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..64e19d532 --- /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..076bc5fa4 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseDeactivateParams.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.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, + string licenseID + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + this.LicenseID = licenseID; + } +#pragma warning restore CS8618 + + /// + public static LicenseDeactivateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData, + string licenseID + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData), + licenseID + ); + } + + 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..be88e4d9c --- /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..c3766a266 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDParams.cs @@ -0,0 +1,155 @@ +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, + string externalLicenseID + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this.ExternalLicenseID = externalLicenseID; + } +#pragma warning restore CS8618 + + /// + public static LicenseRetrieveByExternalIDParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + string externalLicenseID + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalLicenseID + ); + } + + 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..3feeed6b8 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseRetrieveParams.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.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, + string licenseID + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this.LicenseID = licenseID; + } +#pragma warning restore CS8618 + + /// + public static LicenseRetrieveParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + string licenseID + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + licenseID + ); + } + + 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..ff9bfee8c --- /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..82f4835e5 --- /dev/null +++ b/src/Orb/Models/Licenses/Usage/UsageGetUsageParams.cs @@ -0,0 +1,206 @@ +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, + string licenseID + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this.LicenseID = licenseID; + } +#pragma warning restore CS8618 + + /// + public static UsageGetUsageParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + string licenseID + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + licenseID + ); + } + + 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..5b4e2ca53 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, @@ -130,7 +137,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static MetricCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -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..b8ff03a76 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, @@ -37,24 +44,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] MetricFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string metricID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.MetricID = metricID; } #pragma warning restore CS8618 - /// + /// public static MetricFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string metricID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + metricID + ); + } + + 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) @@ -75,4 +114,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/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..b16a4b570 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, @@ -116,7 +123,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static MetricListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -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..ad85e0537 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, @@ -72,27 +79,61 @@ IReadOnlyDictionary rawBodyData MetricUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string metricID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.MetricID = metricID; } #pragma warning restore CS8618 - /// + /// public static MetricUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string metricID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + metricID + ); + } + + 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) @@ -122,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/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..cc88cf62c 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) { @@ -451,7 +468,7 @@ public ConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -472,7 +489,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -492,7 +509,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -503,8 +520,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -533,7 +550,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -544,8 +561,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -637,12 +667,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -659,12 +687,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs b/src/Orb/Models/NewFloatingBulkWithProrationPrice.cs index 5fc419ee5..72957bf3e 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) { @@ -628,7 +651,7 @@ public NewFloatingBulkWithProrationPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -649,7 +672,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -669,7 +692,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -680,8 +703,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -710,7 +733,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -721,8 +744,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -817,12 +853,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -839,12 +873,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs b/src/Orb/Models/NewFloatingCumulativeGroupedBulkPrice.cs index 3f61fd5fc..08d062d49 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) { @@ -645,7 +668,7 @@ public NewFloatingCumulativeGroupedBulkPriceConversionRateConfig(JsonElement ele /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -666,7 +689,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -686,7 +709,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -697,8 +720,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -727,7 +750,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -738,8 +761,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -834,12 +870,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -856,12 +890,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs b/src/Orb/Models/NewFloatingGroupedAllocationPrice.cs index 46ff4e96f..cd3c1ca3b 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) { @@ -561,7 +581,7 @@ public NewFloatingGroupedAllocationPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -582,7 +602,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -602,7 +622,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -613,8 +633,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -643,7 +663,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -654,8 +674,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -750,12 +783,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -772,12 +803,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs b/src/Orb/Models/NewFloatingGroupedTieredPackagePrice.cs index 8ff9423a6..6ed2f4640 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) { @@ -653,7 +676,7 @@ public NewFloatingGroupedTieredPackagePriceConversionRateConfig(JsonElement elem /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -674,7 +697,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -694,7 +717,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -705,8 +728,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -735,7 +758,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -746,8 +769,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -842,12 +878,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -864,12 +898,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingGroupedTieredPrice.cs b/src/Orb/Models/NewFloatingGroupedTieredPrice.cs index fb2537ca4..d2d9034fa 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) { @@ -621,7 +644,7 @@ public NewFloatingGroupedTieredPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -642,7 +665,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -662,7 +685,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -673,8 +696,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -703,7 +726,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -714,8 +737,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -810,12 +846,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -832,12 +866,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs b/src/Orb/Models/NewFloatingGroupedWithMeteredMinimumPrice.cs index 92cfa8ed4..843b0a6b4 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) { @@ -768,7 +794,7 @@ public NewFloatingGroupedWithMeteredMinimumPriceConversionRateConfig(JsonElement /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -789,7 +815,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -809,7 +835,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -820,8 +846,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -850,7 +876,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -861,8 +887,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -957,12 +998,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -979,12 +1018,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs b/src/Orb/Models/NewFloatingGroupedWithProratedMinimumPrice.cs index 2553b6a48..aae86d1b2 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) { @@ -572,7 +592,7 @@ public NewFloatingGroupedWithProratedMinimumPriceConversionRateConfig(JsonElemen /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -593,7 +613,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -613,7 +633,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -624,8 +644,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -654,7 +674,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -665,8 +685,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -763,12 +796,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -785,12 +816,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingMatrixPrice.cs b/src/Orb/Models/NewFloatingMatrixPrice.cs index fd77ce172..4f15dd8d8 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) { @@ -462,7 +479,7 @@ public NewFloatingMatrixPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -483,7 +500,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -503,7 +520,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -514,8 +531,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -544,7 +561,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -555,8 +572,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -651,12 +681,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -673,12 +701,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs b/src/Orb/Models/NewFloatingMatrixWithAllocationPrice.cs index 4e0dc6133..972d000c3 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) { @@ -475,7 +492,7 @@ public NewFloatingMatrixWithAllocationPriceConversionRateConfig(JsonElement elem /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -496,7 +513,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -516,7 +533,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -527,8 +544,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -557,7 +574,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -568,8 +585,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -664,12 +694,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -686,12 +714,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs b/src/Orb/Models/NewFloatingMatrixWithDisplayNamePrice.cs index 2551ddd29..ffc155160 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) { @@ -659,7 +682,7 @@ public NewFloatingMatrixWithDisplayNamePriceConversionRateConfig(JsonElement ele /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -680,7 +703,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -700,7 +723,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -711,8 +734,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -741,7 +764,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -752,8 +775,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -848,12 +884,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -870,12 +904,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs b/src/Orb/Models/NewFloatingMaxGroupTieredPackagePrice.cs index 3632ec4db..4bf2e7a29 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) { @@ -652,7 +675,7 @@ public NewFloatingMaxGroupTieredPackagePriceConversionRateConfig(JsonElement ele /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -673,7 +696,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -693,7 +716,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -704,8 +727,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -734,7 +757,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -745,8 +768,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -841,12 +877,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -863,12 +897,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingMinimumCompositePrice.cs b/src/Orb/Models/NewFloatingMinimumCompositePrice.cs index 669ffc562..af22e3379 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) { @@ -561,7 +581,7 @@ public NewFloatingMinimumCompositePriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -582,7 +602,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -602,7 +622,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -613,8 +633,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -643,7 +663,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -654,8 +674,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -750,12 +783,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -772,12 +803,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingPackagePrice.cs b/src/Orb/Models/NewFloatingPackagePrice.cs index 2068ce0d5..ee9ccc78e 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) { @@ -462,7 +479,7 @@ public NewFloatingPackagePriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -483,7 +500,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -503,7 +520,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -514,8 +531,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -544,7 +561,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -555,8 +572,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -651,12 +681,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -673,12 +701,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs b/src/Orb/Models/NewFloatingPackageWithAllocationPrice.cs index 6b8fea808..3c511b617 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) { @@ -556,7 +576,7 @@ public NewFloatingPackageWithAllocationPriceConversionRateConfig(JsonElement ele /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -577,7 +597,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -597,7 +617,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -608,8 +628,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -638,7 +658,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -649,8 +669,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -745,12 +778,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -767,12 +798,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs b/src/Orb/Models/NewFloatingScalableMatrixWithTieredPricingPrice.cs index d3a79f6ab..fae480cbe 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 @@ -768,7 +794,7 @@ public NewFloatingScalableMatrixWithTieredPricingPriceConversionRateConfig(JsonE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -789,7 +815,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -809,7 +835,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -820,8 +846,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -850,7 +876,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -861,8 +887,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -959,12 +998,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -981,12 +1018,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/NewFloatingScalableMatrixWithUnitPricingPrice.cs index f44f6d75d..ebe46b5e3 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 @@ -705,7 +742,7 @@ public NewFloatingScalableMatrixWithUnitPricingPriceConversionRateConfig(JsonEle /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -726,7 +763,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -746,7 +783,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -757,8 +794,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -787,7 +824,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -798,8 +835,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -896,12 +946,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -918,12 +966,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs b/src/Orb/Models/NewFloatingThresholdTotalAmountPrice.cs index 460aa1a06..2ead91d99 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) { @@ -641,7 +664,7 @@ public NewFloatingThresholdTotalAmountPriceConversionRateConfig(JsonElement elem /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -662,7 +685,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -682,7 +705,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -693,8 +716,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -723,7 +746,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -734,8 +757,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -830,12 +866,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -852,12 +886,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingTieredPackagePrice.cs b/src/Orb/Models/NewFloatingTieredPackagePrice.cs index c62715c8d..1e56e2cad 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) { @@ -621,7 +644,7 @@ public NewFloatingTieredPackagePriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -642,7 +665,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -662,7 +685,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -673,8 +696,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -703,7 +726,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -714,8 +737,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -810,12 +846,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -832,12 +866,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs b/src/Orb/Models/NewFloatingTieredPackageWithMinimumPrice.cs index b3b286c01..66da9771a 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) { @@ -654,7 +677,7 @@ public NewFloatingTieredPackageWithMinimumPriceConversionRateConfig(JsonElement /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -675,7 +698,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -695,7 +718,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -706,8 +729,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -736,7 +759,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -747,8 +770,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -843,12 +881,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -865,12 +901,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingTieredPrice.cs b/src/Orb/Models/NewFloatingTieredPrice.cs index cd30975f6..910a806e3 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) { @@ -462,7 +479,7 @@ public NewFloatingTieredPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -483,7 +500,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -503,7 +520,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -514,8 +531,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -544,7 +561,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -555,8 +572,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -651,12 +681,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -673,12 +701,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs b/src/Orb/Models/NewFloatingTieredWithMinimumPrice.cs index bf420bab6..7cf5f7c2c 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) { @@ -681,7 +704,7 @@ public NewFloatingTieredWithMinimumPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -702,7 +725,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -722,7 +745,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -733,8 +756,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -763,7 +786,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -774,8 +797,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -870,12 +906,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -892,12 +926,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs b/src/Orb/Models/NewFloatingTieredWithProrationPrice.cs index 1b20ff274..7b676164e 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) { @@ -634,7 +657,7 @@ public NewFloatingTieredWithProrationPriceConversionRateConfig(JsonElement eleme /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -655,7 +678,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -675,7 +698,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -686,8 +709,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -716,7 +739,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -727,8 +750,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -823,12 +859,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -845,12 +879,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingUnitPrice.cs b/src/Orb/Models/NewFloatingUnitPrice.cs index a682455b4..626acba03 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) { @@ -461,7 +478,7 @@ public NewFloatingUnitPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -482,7 +499,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -502,7 +519,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -513,8 +530,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -543,7 +560,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -554,8 +571,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -650,12 +680,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -672,12 +700,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs b/src/Orb/Models/NewFloatingUnitWithPercentPrice.cs index c70ae8b52..7ad2c0004 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) { @@ -544,7 +564,7 @@ public NewFloatingUnitWithPercentPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -565,7 +585,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -585,7 +605,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -596,8 +616,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -626,7 +646,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -637,8 +657,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -733,12 +766,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -755,12 +786,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs b/src/Orb/Models/NewFloatingUnitWithProrationPrice.cs index 1e6e13504..f72a1d2c8 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) { @@ -540,7 +560,7 @@ public NewFloatingUnitWithProrationPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -561,7 +581,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -581,7 +601,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -592,8 +612,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -622,7 +642,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -633,8 +653,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -729,12 +762,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -751,12 +782,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } 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..a3a2110ef 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) { @@ -476,7 +493,7 @@ public NewPlanBulkPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -497,7 +514,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -517,7 +534,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -528,8 +545,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -558,7 +575,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -569,8 +586,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -665,12 +695,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -687,12 +715,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanBulkWithProrationPrice.cs b/src/Orb/Models/NewPlanBulkWithProrationPrice.cs index cb43ff72a..e462e3e6d 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 @@ -670,7 +693,7 @@ public NewPlanBulkWithProrationPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -691,7 +714,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -711,7 +734,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -722,8 +745,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -752,7 +775,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -763,8 +786,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -859,12 +895,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -881,12 +915,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs b/src/Orb/Models/NewPlanCumulativeGroupedBulkPrice.cs index 31e8ea177..f88397961 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 @@ -688,7 +711,7 @@ public NewPlanCumulativeGroupedBulkPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -709,7 +732,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -729,7 +752,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -740,8 +763,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -770,7 +793,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -781,8 +804,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -877,12 +913,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -899,12 +933,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanGroupedAllocationPrice.cs b/src/Orb/Models/NewPlanGroupedAllocationPrice.cs index d35081227..9ccb87f76 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 @@ -585,7 +605,7 @@ public NewPlanGroupedAllocationPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -606,7 +626,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -626,7 +646,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -637,8 +657,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -667,7 +687,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -678,8 +698,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -774,12 +807,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -796,12 +827,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs b/src/Orb/Models/NewPlanGroupedTieredPackagePrice.cs index be0dd80d3..42c45f363 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 @@ -683,7 +706,7 @@ public NewPlanGroupedTieredPackagePriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -704,7 +727,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -724,7 +747,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -735,8 +758,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -765,7 +788,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -776,8 +799,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -872,12 +908,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -894,12 +928,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanGroupedTieredPrice.cs b/src/Orb/Models/NewPlanGroupedTieredPrice.cs index 3db6af5e1..1c8e9dba5 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 @@ -660,7 +683,7 @@ public NewPlanGroupedTieredPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -681,7 +704,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -701,7 +724,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -712,8 +735,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -742,7 +765,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -753,8 +776,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -849,12 +885,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -871,12 +905,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs b/src/Orb/Models/NewPlanGroupedWithMeteredMinimumPrice.cs index c6918497f..55b03f896 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 @@ -832,7 +858,7 @@ public NewPlanGroupedWithMeteredMinimumPriceConversionRateConfig(JsonElement ele /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -853,7 +879,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -873,7 +899,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -884,8 +910,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -914,7 +940,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -925,8 +951,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -1021,12 +1060,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1043,12 +1080,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs b/src/Orb/Models/NewPlanGroupedWithProratedMinimumPrice.cs index 9ba2bc2da..49a4c4351 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 @@ -595,7 +615,7 @@ public NewPlanGroupedWithProratedMinimumPriceConversionRateConfig(JsonElement el /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -616,7 +636,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -636,7 +656,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -647,8 +667,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -677,7 +697,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -688,8 +708,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -784,12 +817,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -806,12 +837,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanMatrixPrice.cs b/src/Orb/Models/NewPlanMatrixPrice.cs index 2c6adbee7..f68e1500f 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) { @@ -476,7 +493,7 @@ public NewPlanMatrixPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -497,7 +514,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -517,7 +534,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -528,8 +545,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -558,7 +575,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -569,8 +586,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -665,12 +695,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -687,12 +715,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs b/src/Orb/Models/NewPlanMatrixWithAllocationPrice.cs index bd0f72c43..d0753531f 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) { @@ -490,7 +507,7 @@ public NewPlanMatrixWithAllocationPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -511,7 +528,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -531,7 +548,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -542,8 +559,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -572,7 +589,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -583,8 +600,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -679,12 +709,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -701,12 +729,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs b/src/Orb/Models/NewPlanMatrixWithDisplayNamePrice.cs index b399edc20..f642f063f 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 @@ -691,7 +714,7 @@ public NewPlanMatrixWithDisplayNamePriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -712,7 +735,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -732,7 +755,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -743,8 +766,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -773,7 +796,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -784,8 +807,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -880,12 +916,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -902,12 +936,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs b/src/Orb/Models/NewPlanMaxGroupTieredPackagePrice.cs index f67602ebf..6695b08c2 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 @@ -682,7 +705,7 @@ public NewPlanMaxGroupTieredPackagePriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -703,7 +726,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -723,7 +746,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -734,8 +757,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -764,7 +787,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -775,8 +798,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -871,12 +907,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -893,12 +927,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanMinimumCompositePrice.cs b/src/Orb/Models/NewPlanMinimumCompositePrice.cs index 75f339dea..31b8e99d9 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 @@ -584,7 +604,7 @@ public NewPlanMinimumCompositePriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -605,7 +625,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -625,7 +645,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -636,8 +656,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -666,7 +686,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -677,8 +697,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -773,12 +806,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -795,12 +826,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanPackagePrice.cs b/src/Orb/Models/NewPlanPackagePrice.cs index f0ff05d76..1752cc133 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) { @@ -476,7 +493,7 @@ public NewPlanPackagePriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -497,7 +514,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -517,7 +534,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -528,8 +545,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -558,7 +575,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -569,8 +586,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -665,12 +695,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -687,12 +715,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs b/src/Orb/Models/NewPlanPackageWithAllocationPrice.cs index b5c7793dd..aa6df03e6 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 @@ -581,7 +601,7 @@ public NewPlanPackageWithAllocationPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -602,7 +622,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -622,7 +642,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -633,8 +653,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -663,7 +683,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -674,8 +694,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -770,12 +803,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -792,12 +823,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs b/src/Orb/Models/NewPlanScalableMatrixWithTieredPricingPrice.cs index 706da7ca1..33629d371 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 @@ -813,7 +839,7 @@ public NewPlanScalableMatrixWithTieredPricingPriceConversionRateConfig(JsonEleme /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -834,7 +860,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -854,7 +880,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -865,8 +891,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -895,7 +921,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -906,8 +932,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -1004,12 +1043,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1026,12 +1063,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/NewPlanScalableMatrixWithUnitPricingPrice.cs index b04312f7c..fd9b43308 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 @@ -734,7 +771,7 @@ public NewPlanScalableMatrixWithUnitPricingPriceConversionRateConfig(JsonElement /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -755,7 +792,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -775,7 +812,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -786,8 +823,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -816,7 +853,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -827,8 +864,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -923,12 +975,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -945,12 +995,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs b/src/Orb/Models/NewPlanThresholdTotalAmountPrice.cs index 81d882f08..74076ab7e 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 @@ -684,7 +707,7 @@ public NewPlanThresholdTotalAmountPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -705,7 +728,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -725,7 +748,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -736,8 +759,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -766,7 +789,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -777,8 +800,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -873,12 +909,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -895,12 +929,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanTieredPackagePrice.cs b/src/Orb/Models/NewPlanTieredPackagePrice.cs index 85d60c7c5..ccdf0b541 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 @@ -660,7 +683,7 @@ public NewPlanTieredPackagePriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -681,7 +704,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -701,7 +724,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -712,8 +735,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -742,7 +765,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -753,8 +776,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -849,12 +885,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -871,12 +905,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs b/src/Orb/Models/NewPlanTieredPackageWithMinimumPrice.cs index b17f910c3..464ac8963 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 @@ -685,7 +708,7 @@ public NewPlanTieredPackageWithMinimumPriceConversionRateConfig(JsonElement elem /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -706,7 +729,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -726,7 +749,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -737,8 +760,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -767,7 +790,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -778,8 +801,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -874,12 +910,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -896,12 +930,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanTieredPrice.cs b/src/Orb/Models/NewPlanTieredPrice.cs index 6239140f3..7e55c4d80 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) { @@ -476,7 +493,7 @@ public NewPlanTieredPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -497,7 +514,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -517,7 +534,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -528,8 +545,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -558,7 +575,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -569,8 +586,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -665,12 +695,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -687,12 +715,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs b/src/Orb/Models/NewPlanTieredWithMinimumPrice.cs index 4228c73c2..7d88e5b04 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 @@ -716,7 +739,7 @@ public NewPlanTieredWithMinimumPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -737,7 +760,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -757,7 +780,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -768,8 +791,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -798,7 +821,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -809,8 +832,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -905,12 +941,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -927,12 +961,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanUnitPrice.cs b/src/Orb/Models/NewPlanUnitPrice.cs index 3f2ea1262..006a5fda2 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) { @@ -476,7 +493,7 @@ public NewPlanUnitPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -497,7 +514,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -517,7 +534,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -528,8 +545,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -558,7 +575,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -569,8 +586,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -665,12 +695,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -687,12 +715,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanUnitWithPercentPrice.cs b/src/Orb/Models/NewPlanUnitWithPercentPrice.cs index 6c235d3e5..dd004d780 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 @@ -567,7 +587,7 @@ public NewPlanUnitWithPercentPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -588,7 +608,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -608,7 +628,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -619,8 +639,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -649,7 +669,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -660,8 +680,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -756,12 +789,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -778,12 +809,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/NewPlanUnitWithProrationPrice.cs b/src/Orb/Models/NewPlanUnitWithProrationPrice.cs index e830a05e9..956f2d9cc 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 @@ -564,7 +584,7 @@ public NewPlanUnitWithProrationPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -585,7 +605,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -605,7 +625,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -616,8 +636,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -646,7 +666,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -657,8 +677,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -753,12 +786,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -775,12 +806,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } 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..deec9e0fd 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, @@ -49,26 +56,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] ExternalPlanIDFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalPlanID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalPlanID = externalPlanID; } #pragma warning restore CS8618 - /// + /// public static ExternalPlanIDFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalPlanID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalPlanID ); } + 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 +127,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..9f30a7907 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, @@ -89,29 +96,68 @@ IReadOnlyDictionary rawBodyData ExternalPlanIDUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string otherExternalPlanID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.OtherExternalPlanID = otherExternalPlanID; } #pragma warning restore CS8618 - /// + /// public static ExternalPlanIDUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string otherExternalPlanID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + otherExternalPlanID ); } + 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 +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/Plans/Migrations/MigrationCancelParams.cs b/src/Orb/Models/Plans/Migrations/MigrationCancelParams.cs index 3c14d6e9c..c48f02f08 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, @@ -39,24 +46,62 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] MigrationCancelParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string planID, + string migrationID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.PlanID = planID; + this.MigrationID = migrationID; } #pragma warning restore CS8618 - /// + /// public static MigrationCancelParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string planID, + string migrationID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + planID, + migrationID + ); + } + + 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) @@ -78,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/Migrations/MigrationCancelResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationCancelResponse.cs index 7b94ca3c8..9f8a6a307 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) { @@ -151,7 +154,7 @@ public MigrationCancelResponseEffectiveTime(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -172,7 +175,7 @@ public bool TryPickString([NotNullWhen(true)] out string? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -191,14 +194,14 @@ public bool TryPickDateTimeOffset([NotNullWhen(true)] out System::DateTimeOffset /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type with a TRaw of string and a TEnum of MigrationCancelResponseEffectiveTimeUnionMember2>. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMigrationCancelResponseEffectiveTimeUnionMember2(out var value)) { - /// // `value` is of type `ApiEnum` + /// // `value` is of type `ApiEnum<string, MigrationCancelResponseEffectiveTimeUnionMember2>` /// Console.WriteLine(value); /// } /// @@ -216,7 +219,7 @@ out ApiEnum? value /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -227,9 +230,9 @@ out ApiEnum? value /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, MigrationCancelResponseEffectiveTimeUnionMember2> value) => {...} /// ); /// /// @@ -264,7 +267,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -275,9 +278,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, MigrationCancelResponseEffectiveTimeUnionMember2> value) => {...} /// ); /// /// @@ -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..d5133c287 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, @@ -74,24 +81,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] MigrationListParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string planID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.PlanID = planID; } #pragma warning restore CS8618 - /// + /// public static MigrationListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string planID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + planID + ); + } + + 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) @@ -113,4 +152,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..14c8163c7 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) { @@ -151,7 +154,7 @@ public MigrationListResponseEffectiveTime(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -172,7 +175,7 @@ public bool TryPickString([NotNullWhen(true)] out string? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -191,14 +194,14 @@ public bool TryPickDateTimeOffset([NotNullWhen(true)] out System::DateTimeOffset /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type with a TRaw of string and a TEnum of MigrationListResponseEffectiveTimeUnionMember2>. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickMigrationListResponseEffectiveTimeUnionMember2(out var value)) { - /// // `value` is of type `ApiEnum` + /// // `value` is of type `ApiEnum<string, MigrationListResponseEffectiveTimeUnionMember2>` /// Console.WriteLine(value); /// } /// @@ -216,7 +219,7 @@ out ApiEnum? value /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -227,9 +230,9 @@ out ApiEnum? value /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, MigrationListResponseEffectiveTimeUnionMember2> value) => {...} /// ); /// /// @@ -264,7 +267,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -275,9 +278,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, MigrationListResponseEffectiveTimeUnionMember2> value) => {...} /// ); /// /// @@ -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..fa574f725 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, @@ -39,24 +46,62 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] MigrationRetrieveParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string planID, + string migrationID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.PlanID = planID; + this.MigrationID = migrationID; } #pragma warning restore CS8618 - /// + /// public static MigrationRetrieveParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string planID, + string migrationID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + planID, + migrationID + ); + } + + 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) @@ -78,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/Migrations/MigrationRetrieveResponse.cs b/src/Orb/Models/Plans/Migrations/MigrationRetrieveResponse.cs index 79e6faa81..f12285bdc 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) { @@ -145,7 +146,7 @@ public EffectiveTime(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -166,7 +167,7 @@ public bool TryPickString([NotNullWhen(true)] out string? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -185,14 +186,14 @@ public bool TryPickDateTimeOffset([NotNullWhen(true)] out System::DateTimeOffset /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type with a TRaw of string and a TEnum of UnionMember2>. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickUnionMember2(out var value)) { - /// // `value` is of type `ApiEnum` + /// // `value` is of type `ApiEnum<string, UnionMember2>` /// Console.WriteLine(value); /// } /// @@ -207,7 +208,7 @@ public bool TryPickUnionMember2([NotNullWhen(true)] out ApiEnum /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -218,9 +219,9 @@ public bool TryPickUnionMember2([NotNullWhen(true)] out ApiEnum /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, UnionMember2> value) => {...} /// ); /// /// @@ -253,7 +254,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -264,9 +265,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, UnionMember2> value) => {...} /// ); /// /// @@ -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..5e7f3303c 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" @@ -554,7 +557,7 @@ public PlanAdjustment(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -577,7 +580,7 @@ public bool TryPickPlanPhaseUsageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -600,7 +603,7 @@ public bool TryPickPlanPhaseAmountDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -623,7 +626,7 @@ public bool TryPickPlanPhasePercentageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -646,7 +649,7 @@ public bool TryPickPlanPhaseMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -668,7 +671,7 @@ public bool TryPickPlanPhaseMaximum( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -679,11 +682,11 @@ public bool TryPickPlanPhaseMaximum( /// /// /// instance.Switch( - /// (Models::PlanPhaseUsageDiscountAdjustment value) => {...}, - /// (Models::PlanPhaseAmountDiscountAdjustment value) => {...}, - /// (Models::PlanPhasePercentageDiscountAdjustment value) => {...}, - /// (Models::PlanPhaseMinimumAdjustment value) => {...}, - /// (Models::PlanPhaseMaximumAdjustment value) => {...} + /// (Models::PlanPhaseUsageDiscountAdjustment value) => {...}, + /// (Models::PlanPhaseAmountDiscountAdjustment value) => {...}, + /// (Models::PlanPhasePercentageDiscountAdjustment value) => {...}, + /// (Models::PlanPhaseMinimumAdjustment value) => {...}, + /// (Models::PlanPhaseMaximumAdjustment value) => {...} /// ); /// /// @@ -724,7 +727,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -735,11 +738,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (Models::PlanPhaseUsageDiscountAdjustment value) => {...}, - /// (Models::PlanPhaseAmountDiscountAdjustment value) => {...}, - /// (Models::PlanPhasePercentageDiscountAdjustment value) => {...}, - /// (Models::PlanPhaseMinimumAdjustment value) => {...}, - /// (Models::PlanPhaseMaximumAdjustment value) => {...} + /// (Models::PlanPhaseUsageDiscountAdjustment value) => {...}, + /// (Models::PlanPhaseAmountDiscountAdjustment value) => {...}, + /// (Models::PlanPhasePercentageDiscountAdjustment value) => {...}, + /// (Models::PlanPhaseMinimumAdjustment value) => {...}, + /// (Models::PlanPhaseMaximumAdjustment value) => {...} /// ); /// /// @@ -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 @@ -856,12 +875,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -879,12 +896,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -902,12 +917,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -925,12 +938,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -948,12 +959,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1030,8 +1039,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 +1151,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 +1212,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 +1341,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 +1455,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..fbe497d49 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, @@ -228,7 +229,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static PlanCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -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,776 +1184,710 @@ 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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. + /// 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; } /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -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); - break; - case NewPlanMinimumCompositePrice value: - newPlanMinimumComposite(value); + case MinimumComposite value: + minimumComposite(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" + ); } } @@ -2031,7 +2073,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -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,18 +2402,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2371,18 +2419,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2393,18 +2436,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2415,19 +2453,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2438,18 +2473,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2460,18 +2490,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2482,18 +2507,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -2504,18 +2527,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2526,18 +2544,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -2548,18 +2564,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2570,19 +2581,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2593,19 +2601,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2616,18 +2621,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -2638,18 +2641,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -2660,19 +2661,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2683,18 +2681,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -2705,18 +2701,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -2727,18 +2721,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -2749,19 +2741,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2772,19 +2761,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2795,19 +2781,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2818,19 +2801,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2841,18 +2821,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -2863,19 +2841,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2886,19 +2861,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2909,19 +2881,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2932,19 +2901,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2955,41 +2921,16 @@ 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 ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3000,18 +2941,16 @@ JsonSerializerOptions options { 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) + catch (JsonException) { // ignore } @@ -3022,18 +2961,13 @@ JsonSerializerOptions options { try { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3044,19 +2978,13 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3065,14 +2993,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 +3008,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 +3086,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 +3158,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); } } @@ -3313,7 +3253,20 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } /// - /// User-specified key/value pairs for the resource. Individual keys can be removed + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared /// by setting `metadata` to `null`. /// @@ -3350,19 +3303,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,217 +3326,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 { - /// - /// Property filters to apply (all must match) - /// - public required IReadOnlyList Filters + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class CadenceConverter : JsonConverter +{ + public override Cadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>( - "filters" - ); - } - init + return JsonSerializer.Deserialize(ref reader, options) switch { - this._rawData.Set>( - "filters", - ImmutableArray.ToImmutableArray(value) - ); - } + "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 +{ /// - /// Bulk tiers for rating based on total usage volume + /// The amount of credits granted per active license per cadence. /// - public required IReadOnlyList Tiers + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>( - "tiers" - ); - } - 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(); + return this._rawData.GetNotNullClass("amount"); } + init { this._rawData.Set("amount", value); } } - public BulkWithFiltersConfig() { } - - public BulkWithFiltersConfig( - global::Orb.Models.Plans.BulkWithFiltersConfig bulkWithFiltersConfig - ) - : base(bulkWithFiltersConfig) { } - - 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.Plans.BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class BulkWithFiltersConfigFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Plans.BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.BulkWithFiltersConfig.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 -{ /// - /// Event property key to filter on + /// The currency of the license allocation. /// - public required string PropertyKey + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_key"); + return this._rawData.GetNotNullClass("currency"); } - init { this._rawData.Set("property_key", value); } + init { this._rawData.Set("currency", value); } } /// - /// Event property value to match + /// When True, overage beyond the allocation is written off. /// - public required string PropertyValue + public bool? WriteOffOverage { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); + return this._rawData.GetNullableStruct("write_off_overage"); } - init { this._rawData.Set("property_value", value); } + init { this._rawData.Set("write_off_overage", value); } } /// public override void Validate() { - _ = this.PropertyKey; - _ = this.PropertyValue; + _ = this.Amount; + _ = this.Currency; + _ = this.WriteOffOverage; } - public Filter() { } + public LicenseAllocation() { } - public Filter(global::Orb.Models.Plans.Filter filter) - : base(filter) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseAllocation(LicenseAllocation licenseAllocation) + : base(licenseAllocation) { } +#pragma warning restore CS8618 - public Filter(IReadOnlyDictionary rawData) + public LicenseAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - Filter(FrozenDictionary rawData) + LicenseAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.Filter FromRawUnchecked( + /// + public static LicenseAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -3592,217 +3506,74 @@ IReadOnlyDictionary rawData } } -class FilterFromRaw : IFromRawJson +class LicenseAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Filter.FromRawUnchecked(rawData); + public LicenseAllocation FromRawUnchecked(IReadOnlyDictionary rawData) => + LicenseAllocation.FromRawUnchecked(rawData); } -/// -/// Configuration for a single bulk pricing tier -/// -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class Tier : JsonModel +[JsonConverter(typeof(ConversionRateConfigConverter))] +public record class ConversionRateConfig : ModelBase { - /// - /// 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 object? Value { get; } = null; - /// - /// The lower bound for this tier - /// - public string? TierLowerBound + JsonElement? _element = null; + + public JsonElement Json { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); } - 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) + public ConversionRateConfig(SharedUnitConversionRateConfig value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - Tier(FrozenDictionary rawData) + public ConversionRateConfig(SharedTieredConversionRateConfig value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public ConversionRateConfig(JsonElement element) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this._element = element; } - [SetsRequiredMembers] - public Tier(string unitAmount) - : this() + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) { - 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; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3822,7 +3593,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -3833,8 +3604,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3863,7 +3634,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -3874,8 +3645,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3895,13 +3666,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,80 +3693,31333 @@ 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_prorated_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_metered_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_min_max_thresholds": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "max_group_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "scalable_matrix_with_unit_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - switch (conversionRateType) - { - case "unit": + return new(element); + } + case "minimum_composite": { 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) + catch (JsonException) { // ignore } return new(element); } - case "tiered": + case "percent": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + catch (JsonException) { // ignore } @@ -4006,40 +35028,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 +35117,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 +35176,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 +35272,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +35323,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 +35347,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 +35495,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 +35767,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public PricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -4616,7 +35776,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public PricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -4625,7 +35785,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public PricePriceBulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -4634,7 +35794,7 @@ public TieredWithProrationConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4655,7 +35815,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4675,7 +35835,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4686,8 +35846,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4707,7 +35867,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" ); } } @@ -4716,7 +35876,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4727,8 +35887,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4743,16 +35903,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 +35931,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 +35948,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 @@ -4825,12 +35996,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4847,12 +36016,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4861,16 +36028,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 +36044,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 +36102,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 +36176,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 +36272,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +36324,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 +36347,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 +36389,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 +36411,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 +36422,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 +36442,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 +36458,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 +36632,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 +36659,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public PricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5423,7 +36668,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public PricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5432,7 +36677,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public PricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -5441,7 +36686,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5462,7 +36707,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5482,7 +36727,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -5493,8 +36738,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5514,7 +36759,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" ); } } @@ -5523,7 +36768,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -5534,8 +36779,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5550,16 +36795,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 +36823,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 +36840,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 @@ -5632,12 +36888,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5654,12 +36908,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5668,16 +36920,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 +36937,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 +37071,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 +37167,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +37219,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 +37242,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 +37284,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 +37307,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 +37318,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 +37338,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 +37354,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 +37462,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 +37492,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public PricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6230,7 +37501,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public PricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6239,7 +37510,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public PricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -6248,7 +37519,7 @@ public CumulativeGroupedAllocationConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6269,7 +37540,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6289,7 +37560,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -6300,8 +37571,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6321,7 +37592,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" ); } } @@ -6330,7 +37601,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -6341,8 +37612,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6357,16 +37628,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 +37656,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 @@ -6439,12 +37721,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6461,12 +37741,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6475,16 +37753,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 +37770,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 +37904,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 +38000,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +38052,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 +38075,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 +38117,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 +38140,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 +38151,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 +38171,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 +38187,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 +38325,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public PricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7003,7 +38334,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public PricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7012,7 +38343,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public PricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -7021,7 +38352,7 @@ public MinimumConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7042,7 +38373,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7062,7 +38393,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -7073,8 +38404,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7094,7 +38425,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" ); } } @@ -7103,7 +38434,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -7114,8 +38445,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7130,16 +38461,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 +38489,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 +38506,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 @@ -7209,12 +38554,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7231,12 +38574,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7245,14 +38586,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 +38601,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 +38661,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 +38730,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 +38826,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +38896,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 +38921,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 +38936,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 +38957,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 +38967,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 +38987,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 +39007,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 +39032,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 +39064,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 +39097,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public PricePricePercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7751,7 +39106,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public PricePricePercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7760,7 +39115,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public PricePricePercentConversionRateConfig(JsonElement element) { this._element = element; } @@ -7769,7 +39124,7 @@ public PercentConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7790,7 +39145,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7810,7 +39165,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -7821,8 +39176,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7842,7 +39197,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" ); } } @@ -7851,7 +39206,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -7862,8 +39217,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7878,16 +39233,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 +39261,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 +39278,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 @@ -7958,12 +39326,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7980,12 +39346,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7994,14 +39358,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 +39373,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 +39394,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 +39504,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 +39600,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +39675,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 +39700,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 +39715,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 +39737,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 +39747,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 +39767,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 +39787,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 +39843,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 +39875,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 +39909,7 @@ public JsonElement Json } } - public EventOutputConversionRateConfig( + public PricePriceEventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8537,7 +39918,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig( + public PricePriceEventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8546,7 +39927,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig(JsonElement element) + public PricePriceEventOutputConversionRateConfig(JsonElement element) { this._element = element; } @@ -8555,7 +39936,7 @@ public EventOutputConversionRateConfig(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8576,7 +39957,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8596,7 +39977,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -8607,8 +39988,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8628,7 +40009,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" ); } } @@ -8637,7 +40018,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -8648,8 +40029,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8664,16 +40045,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 +40073,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 +40090,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 @@ -8744,12 +40138,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8766,12 +40158,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8780,14 +40170,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 +40185,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Adjustment : JsonModel { /// @@ -8833,8 +40223,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 +40243,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 +40256,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); } /// @@ -8961,7 +40351,7 @@ public AdjustmentAdjustment(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8982,7 +40372,7 @@ public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDi /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9003,7 +40393,7 @@ public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9024,7 +40414,7 @@ public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9045,7 +40435,7 @@ public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9065,7 +40455,7 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -9076,11 +40466,11 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// @@ -9121,7 +40511,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -9132,11 +40522,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// @@ -9199,10 +40589,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 +40600,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 @@ -9244,12 +40650,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9266,12 +40670,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9288,12 +40690,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9307,12 +40707,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9326,12 +40724,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9398,14 +40794,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 +40815,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 +40855,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 +40865,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 +40875,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 +40894,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 +40912,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 +40929,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..9e5b8ae39 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, @@ -46,26 +53,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] PlanFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string planID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.PlanID = planID; } #pragma warning restore CS8618 - /// + /// public static PlanFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string planID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + planID ); } + 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 +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/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..fa4da000b 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, @@ -142,7 +149,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static PlanListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -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..6de4e33dd 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, @@ -89,29 +96,63 @@ IReadOnlyDictionary rawBodyData PlanUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string planID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.PlanID = planID; } #pragma warning restore CS8618 - /// + /// public static PlanUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string planID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + planID ); } + 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 +180,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Price.cs b/src/Orb/Models/Price.cs index 9a7e02212..86e7428cc 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; @@ -1101,7 +1074,7 @@ public Price(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1122,7 +1095,7 @@ public bool TryPickUnit([NotNullWhen(true)] out Unit? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1143,7 +1116,7 @@ public bool TryPickTiered([NotNullWhen(true)] out Tiered? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1164,7 +1137,7 @@ public bool TryPickBulk([NotNullWhen(true)] out Bulk? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1185,7 +1158,7 @@ public bool TryPickBulkWithFilters([NotNullWhen(true)] out BulkWithFilters? valu /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1206,7 +1179,7 @@ public bool TryPickPackage([NotNullWhen(true)] out Package? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1227,7 +1200,7 @@ public bool TryPickMatrix([NotNullWhen(true)] out Matrix? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1248,7 +1221,7 @@ public bool TryPickThresholdTotalAmount([NotNullWhen(true)] out ThresholdTotalAm /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1269,7 +1242,7 @@ public bool TryPickTieredPackage([NotNullWhen(true)] out TieredPackage? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1290,7 +1263,7 @@ public bool TryPickTieredWithMinimum([NotNullWhen(true)] out TieredWithMinimum? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1311,7 +1284,7 @@ public bool TryPickGroupedTiered([NotNullWhen(true)] out GroupedTiered? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1334,7 +1307,7 @@ public bool TryPickTieredPackageWithMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1355,7 +1328,7 @@ public bool TryPickPackageWithAllocation([NotNullWhen(true)] out PackageWithAllo /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1376,7 +1349,7 @@ public bool TryPickUnitWithPercent([NotNullWhen(true)] out UnitWithPercent? valu /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1397,7 +1370,7 @@ public bool TryPickMatrixWithAllocation([NotNullWhen(true)] out MatrixWithAlloca /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1418,7 +1391,7 @@ public bool TryPickTieredWithProration([NotNullWhen(true)] out TieredWithProrati /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1439,7 +1412,7 @@ public bool TryPickUnitWithProration([NotNullWhen(true)] out UnitWithProration? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1460,7 +1433,7 @@ public bool TryPickGroupedAllocation([NotNullWhen(true)] out GroupedAllocation? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1481,7 +1454,7 @@ public bool TryPickBulkWithProration([NotNullWhen(true)] out BulkWithProration? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1504,7 +1477,7 @@ public bool TryPickGroupedWithProratedMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1527,7 +1500,7 @@ public bool TryPickGroupedWithMeteredMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1550,7 +1523,7 @@ public bool TryPickGroupedWithMinMaxThresholds( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1571,7 +1544,7 @@ public bool TryPickMatrixWithDisplayName([NotNullWhen(true)] out MatrixWithDispl /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1592,7 +1565,7 @@ public bool TryPickGroupedTieredPackage([NotNullWhen(true)] out GroupedTieredPac /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1613,7 +1586,7 @@ public bool TryPickMaxGroupTieredPackage([NotNullWhen(true)] out MaxGroupTieredP /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1636,7 +1609,7 @@ public bool TryPickScalableMatrixWithUnitPricing( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1659,7 +1632,7 @@ public bool TryPickScalableMatrixWithTieredPricing( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1680,7 +1653,7 @@ public bool TryPickCumulativeGroupedBulk([NotNullWhen(true)] out CumulativeGroup /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1699,32 +1672,11 @@ 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 . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1745,7 +1697,7 @@ public bool TryPickMinimumComposite([NotNullWhen(true)] out MinimumComposite? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1766,7 +1718,7 @@ public bool TryPickPercent([NotNullWhen(true)] out Percent? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1786,7 +1738,7 @@ public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1797,38 +1749,37 @@ public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) /// /// /// instance.Switch( - /// (Unit value) => {...}, - /// (Tiered value) => {...}, - /// (Bulk value) => {...}, - /// (BulkWithFilters value) => {...}, - /// (Package value) => {...}, - /// (Matrix value) => {...}, - /// (ThresholdTotalAmount value) => {...}, - /// (TieredPackage value) => {...}, - /// (TieredWithMinimum value) => {...}, - /// (GroupedTiered value) => {...}, - /// (TieredPackageWithMinimum value) => {...}, - /// (PackageWithAllocation value) => {...}, - /// (UnitWithPercent value) => {...}, - /// (MatrixWithAllocation value) => {...}, - /// (TieredWithProration value) => {...}, - /// (UnitWithProration value) => {...}, - /// (GroupedAllocation value) => {...}, - /// (BulkWithProration value) => {...}, - /// (GroupedWithProratedMinimum value) => {...}, - /// (GroupedWithMeteredMinimum value) => {...}, - /// (GroupedWithMinMaxThresholds value) => {...}, - /// (MatrixWithDisplayName value) => {...}, - /// (GroupedTieredPackage value) => {...}, - /// (MaxGroupTieredPackage value) => {...}, - /// (ScalableMatrixWithUnitPricing value) => {...}, - /// (ScalableMatrixWithTieredPricing value) => {...}, - /// (CumulativeGroupedBulk value) => {...}, - /// (CumulativeGroupedAllocation value) => {...}, - /// (PriceMinimum value) => {...}, - /// (MinimumComposite value) => {...}, - /// (Percent value) => {...}, - /// (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) => {...} /// ); /// /// @@ -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; @@ -1975,7 +1922,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1986,38 +1933,37 @@ public void Switch( /// /// /// var result = instance.Match( - /// (Unit value) => {...}, - /// (Tiered value) => {...}, - /// (Bulk value) => {...}, - /// (BulkWithFilters value) => {...}, - /// (Package value) => {...}, - /// (Matrix value) => {...}, - /// (ThresholdTotalAmount value) => {...}, - /// (TieredPackage value) => {...}, - /// (TieredWithMinimum value) => {...}, - /// (GroupedTiered value) => {...}, - /// (TieredPackageWithMinimum value) => {...}, - /// (PackageWithAllocation value) => {...}, - /// (UnitWithPercent value) => {...}, - /// (MatrixWithAllocation value) => {...}, - /// (TieredWithProration value) => {...}, - /// (UnitWithProration value) => {...}, - /// (GroupedAllocation value) => {...}, - /// (BulkWithProration value) => {...}, - /// (GroupedWithProratedMinimum value) => {...}, - /// (GroupedWithMeteredMinimum value) => {...}, - /// (GroupedWithMinMaxThresholds value) => {...}, - /// (MatrixWithDisplayName value) => {...}, - /// (GroupedTieredPackage value) => {...}, - /// (MaxGroupTieredPackage value) => {...}, - /// (ScalableMatrixWithUnitPricing value) => {...}, - /// (ScalableMatrixWithTieredPricing value) => {...}, - /// (CumulativeGroupedBulk value) => {...}, - /// (CumulativeGroupedAllocation value) => {...}, - /// (PriceMinimum value) => {...}, - /// (MinimumComposite value) => {...}, - /// (Percent value) => {...}, - /// (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) => {...} /// ); /// /// @@ -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 @@ -2253,12 +2236,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2272,12 +2253,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2291,12 +2270,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2313,12 +2290,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2332,12 +2307,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2351,12 +2324,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2373,12 +2344,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2392,12 +2361,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2414,12 +2381,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2433,12 +2398,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2455,12 +2418,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2477,12 +2438,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2499,12 +2458,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2521,12 +2478,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2543,12 +2498,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2565,12 +2518,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2587,12 +2538,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2609,12 +2558,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2631,12 +2578,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2653,12 +2598,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2675,12 +2618,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2697,12 +2638,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2719,12 +2658,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2741,12 +2678,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2763,12 +2698,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2785,12 +2718,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2807,12 +2738,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2829,31 +2758,10 @@ JsonSerializerOptions options ); if (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) + catch (JsonException) { // ignore } @@ -2870,12 +2778,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2889,12 +2795,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2908,12 +2812,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3262,6 +3164,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 +3216,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.UnitConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -3309,11 +3227,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 +3433,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) { @@ -3693,7 +3617,7 @@ public UnitConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3714,7 +3638,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3734,7 +3658,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -3745,8 +3669,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3775,7 +3699,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -3786,8 +3710,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3836,10 +3760,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 +3771,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 @@ -3881,12 +3818,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3903,12 +3838,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3979,6 +3912,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 +4334,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 +4386,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -4357,11 +4397,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 +4605,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) { @@ -4745,7 +4791,7 @@ public TieredConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4766,7 +4812,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4786,7 +4832,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4797,8 +4843,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4827,7 +4873,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4838,8 +4884,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4888,10 +4934,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 +4945,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 @@ -4933,12 +4992,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4955,12 +5012,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5031,6 +5086,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 +5508,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 +5560,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -5407,11 +5571,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 +5779,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) { @@ -5794,7 +5964,7 @@ public BulkConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5815,7 +5985,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5835,7 +6005,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -5846,8 +6016,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5876,7 +6046,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -5887,8 +6057,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5937,10 +6107,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 +6118,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 @@ -5982,12 +6165,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6004,12 +6185,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6080,6 +6259,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 +6685,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 +6742,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -6467,11 +6753,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 +6904,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 +6983,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 +7062,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 +7228,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) { @@ -7115,7 +7416,7 @@ public BulkWithFiltersConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7136,7 +7437,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7156,7 +7457,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -7167,8 +7468,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7197,7 +7498,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -7208,8 +7509,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7258,10 +7559,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 +7570,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 @@ -7304,12 +7618,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7326,12 +7638,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7402,6 +7712,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 +8139,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 +8191,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -7780,11 +8202,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 +8410,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) { @@ -8168,7 +8596,7 @@ public PackageConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8189,7 +8617,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8209,7 +8637,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -8220,8 +8648,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8250,7 +8678,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -8261,8 +8689,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8311,10 +8739,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 +8750,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 @@ -8356,12 +8797,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8378,12 +8817,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8454,6 +8891,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 +9315,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 +9367,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -8832,11 +9378,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 +9586,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) { @@ -9220,7 +9772,7 @@ public MatrixConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9241,7 +9793,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9261,7 +9813,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -9272,8 +9824,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9302,7 +9854,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -9313,8 +9865,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9363,10 +9915,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 +9926,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 @@ -9408,12 +9973,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9430,12 +9993,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9506,6 +10067,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 +10497,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 +10554,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.ThresholdTotalAmountConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -9895,11 +10565,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 +10780,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 @@ -10295,7 +10971,7 @@ public ThresholdTotalAmountConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -10316,7 +10992,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -10336,7 +11012,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -10347,8 +11023,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -10377,7 +11053,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -10388,8 +11064,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -10438,10 +11114,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 +11125,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 @@ -10484,12 +11173,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -10506,12 +11193,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -10639,10 +11324,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 +11418,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 +11461,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 +11897,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 +11954,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredPackageConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -11157,11 +11965,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 +12176,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) { @@ -11550,7 +12364,7 @@ public TieredPackageConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -11571,7 +12385,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -11591,7 +12405,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -11602,8 +12416,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -11632,7 +12446,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -11643,8 +12457,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -11693,10 +12507,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 +12518,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 @@ -11739,12 +12566,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -11761,12 +12586,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -11894,10 +12717,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 +12798,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 +12837,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 +13270,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 +13327,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredWithMinimumConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -12397,11 +13338,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 +13551,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) { @@ -12793,7 +13740,7 @@ public TieredWithMinimumConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -12814,7 +13761,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -12834,7 +13781,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -12845,8 +13792,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -12875,7 +13822,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -12886,8 +13833,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -12936,10 +13883,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 +13894,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 @@ -12982,12 +13942,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -13004,12 +13962,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -13168,10 +14124,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 +14228,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 +14269,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 +14700,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 +14757,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -13694,11 +14768,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 +14979,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) { @@ -14087,7 +15167,7 @@ public GroupedTieredConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -14108,7 +15188,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -14128,7 +15208,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -14139,8 +15219,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14169,7 +15249,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -14180,8 +15260,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14230,10 +15310,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 +15321,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 @@ -14276,12 +15369,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14298,12 +15389,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14384,10 +15473,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 +15554,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 +15640,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 +16075,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 +16134,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredPackageWithMinimumConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -14936,11 +16145,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 +16361,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 @@ -15338,7 +16553,7 @@ public TieredPackageWithMinimumConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -15359,7 +16574,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -15379,7 +16594,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -15390,8 +16605,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15420,7 +16635,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -15431,8 +16646,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15481,10 +16696,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 +16707,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 @@ -15527,12 +16755,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -15549,12 +16775,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -15680,10 +16904,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 +16998,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 +17041,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 +17479,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 +17536,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -16200,11 +17547,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 +17762,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 @@ -16600,7 +17953,7 @@ public PackageWithAllocationConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -16621,7 +17974,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -16641,7 +17994,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -16652,8 +18005,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16682,7 +18035,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -16693,8 +18046,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16743,10 +18096,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 +18107,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 @@ -16789,12 +18155,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -16811,12 +18175,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -16891,10 +18253,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 +18341,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 +18779,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 +18836,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.UnitWithPercentConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -17365,11 +18847,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 +19058,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) { @@ -17758,7 +19246,7 @@ public UnitWithPercentConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -17779,7 +19267,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -17799,7 +19287,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -17810,8 +19298,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17840,7 +19328,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -17851,8 +19339,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17901,10 +19389,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 +19400,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 @@ -17947,12 +19448,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -17969,12 +19468,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -18091,10 +19588,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 +19627,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 +20060,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 +20117,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -18516,11 +20128,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 +20343,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 @@ -18916,7 +20534,7 @@ public MatrixWithAllocationConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -18937,7 +20555,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -18957,7 +20575,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -18968,8 +20586,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18998,7 +20616,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -19009,8 +20627,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19059,10 +20677,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 +20688,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 @@ -19105,12 +20736,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -19127,12 +20756,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -19203,6 +20830,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 +21268,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 +21325,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredWithProrationConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -19592,11 +21336,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 +21549,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) { @@ -19988,7 +21738,7 @@ public TieredWithProrationConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -20009,7 +21759,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -20029,7 +21779,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -20040,8 +21790,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -20070,7 +21820,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -20081,8 +21831,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -20131,10 +21881,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 +21892,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 @@ -20177,12 +21940,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -20199,12 +21960,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -20319,10 +22078,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 +22174,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 +22215,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 +22653,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 +22710,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.UnitWithProrationConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -20839,11 +22721,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 +22934,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) { @@ -21235,7 +23123,7 @@ public UnitWithProrationConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -21256,7 +23144,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -21276,7 +23164,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -21287,8 +23175,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -21317,7 +23205,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -21328,8 +23216,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -21378,10 +23266,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 +23277,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 @@ -21424,12 +23325,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -21446,12 +23345,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -21554,10 +23451,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 +23499,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 +23932,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 +23989,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -21988,11 +24000,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 +24213,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) { @@ -22384,7 +24402,7 @@ public GroupedAllocationConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -22405,7 +24423,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -22425,7 +24443,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -22436,8 +24454,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -22466,7 +24484,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -22477,8 +24495,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -22527,10 +24545,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 +24556,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 @@ -22573,12 +24604,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -22595,12 +24624,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -22684,10 +24711,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 +24799,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 +25232,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 +25289,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -23158,11 +25300,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 +25433,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 +25529,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 +25700,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) { @@ -23735,7 +25889,7 @@ public BulkWithProrationConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -23756,7 +25910,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -23776,7 +25930,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -23787,8 +25941,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -23817,7 +25971,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -23828,8 +25982,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -23878,10 +26032,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 +26043,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 @@ -23924,12 +26091,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -23946,12 +26111,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -24022,6 +26185,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 +26620,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 +26679,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -24413,11 +26690,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 +26906,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 @@ -24815,7 +27098,7 @@ public GroupedWithProratedMinimumConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -24836,7 +27119,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -24856,7 +27139,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -24867,8 +27150,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -24897,7 +27180,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -24908,8 +27191,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -24958,10 +27241,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 +27252,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 @@ -25004,12 +27300,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -25026,12 +27320,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -25115,10 +27407,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 +27498,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 +27939,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 +27998,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -25594,11 +28009,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 +28225,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 @@ -25996,7 +28417,7 @@ public GroupedWithMeteredMinimumConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -26017,7 +28438,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -26037,7 +28458,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -26048,8 +28469,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -26078,7 +28499,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -26089,8 +28510,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -26139,10 +28560,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 +28571,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 @@ -26185,12 +28619,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -26207,12 +28639,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -26360,10 +28790,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 +28874,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 +28964,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 +29058,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 +29499,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 +29558,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -27010,11 +29569,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 +29788,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 @@ -27415,7 +29980,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -27436,7 +30001,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -27456,7 +30021,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -27467,8 +30032,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -27497,7 +30062,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -27508,8 +30073,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -27558,10 +30123,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 +30134,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 @@ -27604,12 +30182,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -27626,12 +30202,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -27729,10 +30303,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 +30389,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 +30828,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 +30885,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -28201,11 +30896,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 +31111,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 @@ -28601,7 +31302,7 @@ public MatrixWithDisplayNameConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -28622,7 +31323,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -28642,7 +31343,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -28653,8 +31354,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -28683,7 +31384,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -28694,8 +31395,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -28744,10 +31445,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 +31456,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 @@ -28790,12 +31504,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -28812,12 +31524,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -28897,10 +31607,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 +31708,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 +31798,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 +32236,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 +32293,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -29471,11 +32304,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 +32519,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 @@ -29871,7 +32710,7 @@ public GroupedTieredPackageConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -29892,7 +32731,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -29912,7 +32751,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -29923,8 +32762,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -29953,7 +32792,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -29964,8 +32803,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -30014,10 +32853,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 +32864,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 @@ -30060,12 +32912,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -30082,12 +32932,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -30180,10 +33028,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 +33112,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 +33202,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 +33640,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 +33697,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -30737,11 +33708,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 +33923,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 @@ -31137,7 +34114,7 @@ public MaxGroupTieredPackageConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -31158,7 +34135,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -31178,7 +34155,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -31189,8 +34166,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -31219,7 +34196,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -31230,8 +34207,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -31280,10 +34257,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 +34268,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 @@ -31326,12 +34316,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -31348,12 +34336,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -31445,10 +34431,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 +34515,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 +34605,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 +35045,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 +35104,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.ScalableMatrixWithUnitPricingConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -32004,6 +35115,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 +35124,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 +35336,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 @@ -32412,7 +35529,7 @@ public ScalableMatrixWithUnitPricingConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -32433,7 +35550,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -32453,7 +35570,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -32464,8 +35581,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -32494,7 +35611,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -32505,8 +35622,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -32555,10 +35672,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 +35683,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 @@ -32601,12 +35731,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -32623,12 +35751,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -32758,6 +35884,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 +35932,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 +36034,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 +36081,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 +36527,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 +36586,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.ScalableMatrixWithTieredPricingConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -33329,6 +36597,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 +36606,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 +36818,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 @@ -33739,7 +37013,7 @@ public ScalableMatrixWithTieredPricingConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -33760,7 +37034,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -33780,7 +37054,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -33791,8 +37065,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -33821,7 +37095,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -33832,8 +37106,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -33882,10 +37156,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 +37167,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 @@ -33928,12 +37215,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -33950,12 +37235,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -34119,10 +37402,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 +37501,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 +37590,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 +37636,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 +38077,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 +38134,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -34733,11 +38145,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 +38360,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 @@ -35133,1282 +38551,7 @@ public CumulativeGroupedBulkConversionRateConfig(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.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) - { - value = this.Value as SharedUnitConversionRateConfig; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) - { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.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) - { - 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -36429,7 +38572,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -36449,7 +38592,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -36460,8 +38603,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -36481,7 +38624,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of CumulativeGroupedBulkConversionRateConfig" ); } } @@ -36490,7 +38633,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -36501,8 +38644,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -36517,16 +38660,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 +38688,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 +38705,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 @@ -36597,12 +38753,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -36619,12 +38773,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -36633,14 +38785,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 +38801,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 +38920,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 +38948,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 +38989,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 +39016,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 +39033,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 +39045,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 +39183,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 +39235,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 +39267,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 +39414,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 +39447,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 +39485,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 +39518,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 +39530,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 +39544,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 +39579,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 +39620,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 +39636,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 +39647,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(PriceMinimumCadenceConverter))] -public enum PriceMinimumCadence +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] +public enum CumulativeGroupedAllocationCadence { OneTime, Monthly, @@ -37281,9 +39658,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 +39669,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 +39689,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 +39706,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 +39730,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 +39772,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 +39806,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 +39828,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 +39839,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 +39858,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 +39876,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 +39894,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 +39910,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 +39921,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 +39939,7 @@ public JsonElement Json } } - public PriceMinimumConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -37560,7 +39948,7 @@ public PriceMinimumConversionRateConfig( this._element = element; } - public PriceMinimumConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -37569,7 +39957,7 @@ public PriceMinimumConversionRateConfig( this._element = element; } - public PriceMinimumConversionRateConfig(JsonElement element) + public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -37578,7 +39966,7 @@ public PriceMinimumConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -37599,7 +39987,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -37619,7 +40007,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -37630,8 +40018,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -37651,7 +40039,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" ); } } @@ -37660,7 +40048,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -37671,8 +40059,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -37687,16 +40075,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 +40103,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 +40120,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 @@ -37767,12 +40168,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -37789,12 +40188,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -37803,14 +40200,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 +40216,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 +40346,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 +40363,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 +40375,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 +40814,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 +40871,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -38340,11 +40882,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 +41095,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) { @@ -38736,7 +41284,7 @@ public MinimumCompositeConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -38757,7 +41305,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -38777,7 +41325,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -38788,8 +41336,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -38818,7 +41366,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -38829,8 +41377,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -38879,10 +41427,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 +41438,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 @@ -38925,12 +41486,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -38947,12 +41506,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -39030,10 +41587,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 +41680,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 +42107,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 +42159,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -39498,11 +42170,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 +42378,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) { @@ -39886,7 +42564,7 @@ public PercentConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -39907,7 +42585,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -39927,7 +42605,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -39938,8 +42616,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -39968,7 +42646,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -39979,8 +42657,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -40029,10 +42707,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 +42718,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 @@ -40074,12 +42765,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -40096,12 +42785,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -40152,8 +42839,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 +42926,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 +43352,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 +43409,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -40621,11 +43420,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 +43631,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) { @@ -41014,7 +43819,7 @@ public EventOutputConversionRateConfig(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -41035,7 +43840,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -41055,7 +43860,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -41066,8 +43871,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -41096,7 +43901,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -41107,8 +43912,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -41157,10 +43962,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 +43973,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 @@ -41203,12 +44021,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -41225,12 +44041,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -41312,8 +44126,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 +44214,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..71f4a9797 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) { @@ -148,7 +151,7 @@ public GroupingValue(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -169,7 +172,7 @@ public bool TryPickString([NotNullWhen(true)] out string? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -190,7 +193,7 @@ public bool TryPickDouble([NotNullWhen(true)] out double? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -210,7 +213,7 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -221,9 +224,9 @@ public bool TryPickBool([NotNullWhen(true)] out bool? value) /// /// /// instance.Switch( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -256,7 +259,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -267,9 +270,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (double value) => {...}, - /// (bool value) => {...} + /// (string value) => {...}, + /// (double value) => {...}, + /// (bool value) => {...} /// ); /// /// @@ -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..14adc12e4 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, @@ -37,24 +44,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] ExternalPriceIDFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalPriceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalPriceID = externalPriceID; } #pragma warning restore CS8618 - /// + /// public static ExternalPriceIDFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalPriceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalPriceID + ); + } + + 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) @@ -76,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/Prices/ExternalPriceID/ExternalPriceIDUpdateParams.cs b/src/Orb/Models/Prices/ExternalPriceID/ExternalPriceIDUpdateParams.cs index dcbbe1f77..5b982ecb9 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, @@ -72,27 +79,63 @@ IReadOnlyDictionary rawBodyData ExternalPriceIDUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string externalPriceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ExternalPriceID = externalPriceID; } #pragma warning restore CS8618 - /// + /// public static ExternalPriceIDUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string externalPriceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + externalPriceID + ); + } + + 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) @@ -123,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/Prices/PriceCreateParams.cs b/src/Orb/Models/Prices/PriceCreateParams.cs index fcf7c47b7..eb7b78f51 100644 --- a/src/Orb/Models/Prices/PriceCreateParams.cs +++ b/src/Orb/Models/Prices/PriceCreateParams.cs @@ -23,45 +23,44 @@ 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 - { - get { return this._rawBodyData.Freeze(); } - } + public JsonElement RawBodyData { get; private init; } /// /// New floating price request body params. /// public required Body Body { - get - { - this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullClass("body"); - } - init { this._rawBodyData.Set("body", value); } + get { return WrappedJsonSerializer.GetNotNullClass(this.RawBodyData, "RawBodyData"); } + init { this.RawBodyData = JsonSerializer.SerializeToElement(value); } } public PriceCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceCreateParams(PriceCreateParams priceCreateParams) : base(priceCreateParams) { - this._rawBodyData = new(priceCreateParams._rawBodyData); + this.RawBodyData = priceCreateParams.RawBodyData; } +#pragma warning restore CS8618 public PriceCreateParams( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + JsonElement rawBodyData ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; } #pragma warning disable CS8618 @@ -69,27 +68,55 @@ IReadOnlyDictionary rawBodyData PriceCreateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + JsonElement rawBodyData ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; } #pragma warning restore CS8618 - /// + /// public static PriceCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + JsonElement rawBodyData ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + 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), + } + ), + 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) @@ -117,6 +144,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -173,7 +205,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 +245,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 +285,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 +325,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 +365,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 +405,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 +445,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 +487,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 +527,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 +567,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 +607,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 +648,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 +655,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 +713,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 +815,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 +857,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 +869,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; @@ -842,7 +890,7 @@ public Body(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -863,7 +911,7 @@ public bool TryPickNewFloatingUnitPrice([NotNullWhen(true)] out NewFloatingUnitP /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -884,7 +932,7 @@ public bool TryPickNewFloatingTieredPrice([NotNullWhen(true)] out NewFloatingTie /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -903,24 +951,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. + /// 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; } @@ -928,7 +974,7 @@ public bool TryPickBulkWithFilters( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -951,7 +997,7 @@ public bool TryPickNewFloatingPackagePrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -972,7 +1018,7 @@ public bool TryPickNewFloatingMatrixPrice([NotNullWhen(true)] out NewFloatingMat /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -995,7 +1041,7 @@ public bool TryPickNewFloatingThresholdTotalAmountPrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1018,7 +1064,7 @@ public bool TryPickNewFloatingTieredPackagePrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1041,7 +1087,7 @@ public bool TryPickNewFloatingTieredWithMinimumPrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1064,7 +1110,7 @@ public bool TryPickNewFloatingGroupedTieredPrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1087,7 +1133,7 @@ public bool TryPickNewFloatingTieredPackageWithMinimumPrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1110,7 +1156,7 @@ public bool TryPickNewFloatingPackageWithAllocationPrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1133,7 +1179,7 @@ public bool TryPickNewFloatingUnitWithPercentPrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1156,7 +1202,7 @@ public bool TryPickNewFloatingMatrixWithAllocationPrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1179,7 +1225,7 @@ public bool TryPickNewFloatingTieredWithProrationPrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1202,7 +1248,7 @@ public bool TryPickNewFloatingUnitWithProrationPrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1225,7 +1271,7 @@ public bool TryPickNewFloatingGroupedAllocationPrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1248,7 +1294,7 @@ public bool TryPickNewFloatingBulkWithProrationPrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1271,7 +1317,7 @@ public bool TryPickNewFloatingGroupedWithProratedMinimumPrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1292,24 +1338,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. + /// 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; } @@ -1317,7 +1363,7 @@ public bool TryPickGroupedWithMinMaxThresholds( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1340,7 +1386,7 @@ public bool TryPickNewFloatingMatrixWithDisplayNamePrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1363,7 +1409,7 @@ public bool TryPickNewFloatingGroupedTieredPackagePrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1386,7 +1432,7 @@ public bool TryPickNewFloatingMaxGroupTieredPackagePrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1409,7 +1455,7 @@ public bool TryPickNewFloatingScalableMatrixWithUnitPricingPrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1432,7 +1478,7 @@ public bool TryPickNewFloatingScalableMatrixWithTieredPricingPrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1453,45 +1499,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. + /// 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; } @@ -1499,7 +1524,7 @@ public bool TryPickMinimum([NotNullWhen(true)] out global::Orb.Models.Prices.Min /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1520,52 +1545,50 @@ 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. + /// 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. + /// 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; } /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1576,38 +1599,37 @@ public bool TryPickEventOutput( /// /// /// instance.Switch( - /// (NewFloatingUnitPrice value) => {...}, - /// (NewFloatingTieredPrice value) => {...}, - /// (NewFloatingBulkPrice value) => {...}, - /// (global::Orb.Models.Prices.BulkWithFilters value) => {...}, - /// (NewFloatingPackagePrice value) => {...}, - /// (NewFloatingMatrixPrice value) => {...}, - /// (NewFloatingThresholdTotalAmountPrice value) => {...}, - /// (NewFloatingTieredPackagePrice value) => {...}, - /// (NewFloatingTieredWithMinimumPrice value) => {...}, - /// (NewFloatingGroupedTieredPrice value) => {...}, - /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, - /// (NewFloatingPackageWithAllocationPrice value) => {...}, - /// (NewFloatingUnitWithPercentPrice value) => {...}, - /// (NewFloatingMatrixWithAllocationPrice value) => {...}, - /// (NewFloatingTieredWithProrationPrice value) => {...}, - /// (NewFloatingUnitWithProrationPrice value) => {...}, - /// (NewFloatingGroupedAllocationPrice value) => {...}, - /// (NewFloatingBulkWithProrationPrice value) => {...}, - /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, - /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Prices.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) => {...}, - /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Prices.Percent value) => {...}, - /// (global::Orb.Models.Prices.EventOutput value) => {...} + /// (NewFloatingUnitPrice value) => {...}, + /// (NewFloatingTieredPrice value) => {...}, + /// (NewFloatingBulkPrice value) => {...}, + /// (BulkWithFilters value) => {...}, + /// (NewFloatingPackagePrice value) => {...}, + /// (NewFloatingMatrixPrice value) => {...}, + /// (NewFloatingThresholdTotalAmountPrice value) => {...}, + /// (NewFloatingTieredPackagePrice value) => {...}, + /// (NewFloatingTieredWithMinimumPrice value) => {...}, + /// (NewFloatingGroupedTieredPrice value) => {...}, + /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, + /// (NewFloatingPackageWithAllocationPrice value) => {...}, + /// (NewFloatingUnitWithPercentPrice value) => {...}, + /// (NewFloatingMatrixWithAllocationPrice value) => {...}, + /// (NewFloatingTieredWithProrationPrice value) => {...}, + /// (NewFloatingUnitWithProrationPrice value) => {...}, + /// (NewFloatingGroupedAllocationPrice value) => {...}, + /// (NewFloatingBulkWithProrationPrice value) => {...}, + /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, + /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, + /// (NewFloatingGroupedTieredPackagePrice value) => {...}, + /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, + /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -1616,7 +1638,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 +1655,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 +1679,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 +1730,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 +1751,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: @@ -1754,7 +1772,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1765,38 +1783,37 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewFloatingUnitPrice value) => {...}, - /// (NewFloatingTieredPrice value) => {...}, - /// (NewFloatingBulkPrice value) => {...}, - /// (global::Orb.Models.Prices.BulkWithFilters value) => {...}, - /// (NewFloatingPackagePrice value) => {...}, - /// (NewFloatingMatrixPrice value) => {...}, - /// (NewFloatingThresholdTotalAmountPrice value) => {...}, - /// (NewFloatingTieredPackagePrice value) => {...}, - /// (NewFloatingTieredWithMinimumPrice value) => {...}, - /// (NewFloatingGroupedTieredPrice value) => {...}, - /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, - /// (NewFloatingPackageWithAllocationPrice value) => {...}, - /// (NewFloatingUnitWithPercentPrice value) => {...}, - /// (NewFloatingMatrixWithAllocationPrice value) => {...}, - /// (NewFloatingTieredWithProrationPrice value) => {...}, - /// (NewFloatingUnitWithProrationPrice value) => {...}, - /// (NewFloatingGroupedAllocationPrice value) => {...}, - /// (NewFloatingBulkWithProrationPrice value) => {...}, - /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, - /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Prices.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) => {...}, - /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Prices.Percent value) => {...}, - /// (global::Orb.Models.Prices.EventOutput value) => {...} + /// (NewFloatingUnitPrice value) => {...}, + /// (NewFloatingTieredPrice value) => {...}, + /// (NewFloatingBulkPrice value) => {...}, + /// (BulkWithFilters value) => {...}, + /// (NewFloatingPackagePrice value) => {...}, + /// (NewFloatingMatrixPrice value) => {...}, + /// (NewFloatingThresholdTotalAmountPrice value) => {...}, + /// (NewFloatingTieredPackagePrice value) => {...}, + /// (NewFloatingTieredWithMinimumPrice value) => {...}, + /// (NewFloatingGroupedTieredPrice value) => {...}, + /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, + /// (NewFloatingPackageWithAllocationPrice value) => {...}, + /// (NewFloatingUnitWithPercentPrice value) => {...}, + /// (NewFloatingMatrixWithAllocationPrice value) => {...}, + /// (NewFloatingTieredWithProrationPrice value) => {...}, + /// (NewFloatingUnitWithProrationPrice value) => {...}, + /// (NewFloatingGroupedAllocationPrice value) => {...}, + /// (NewFloatingBulkWithProrationPrice value) => {...}, + /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, + /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, + /// (NewFloatingGroupedTieredPackagePrice value) => {...}, + /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, + /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -1805,7 +1822,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 +1851,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 +1873,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 +1884,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 +1910,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 +1927,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 +1941,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 +1978,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 +1994,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 +2059,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 +2076,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 @@ -2111,12 +2152,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2133,12 +2172,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2155,12 +2192,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2171,19 +2206,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2200,12 +2232,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2222,12 +2252,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2245,12 +2273,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2267,12 +2293,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2290,12 +2314,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2312,12 +2334,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2335,12 +2355,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2358,12 +2376,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2380,12 +2396,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2403,12 +2417,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2426,12 +2438,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2449,12 +2459,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2472,12 +2480,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2495,12 +2501,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2518,12 +2522,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2541,12 +2543,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2557,19 +2557,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2587,12 +2584,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2610,12 +2605,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2633,12 +2626,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2656,12 +2647,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2679,12 +2668,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2702,12 +2689,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2718,42 +2703,16 @@ 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(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2770,12 +2729,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2786,19 +2743,13 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2809,19 +2760,13 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2841,25 +2786,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 +2805,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 +2926,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 +3006,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +3067,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -3128,8 +3076,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 +3097,39 @@ public BulkWithFilters(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class BulkWithFiltersFromRaw : IFromRawJson +class BulkWithFiltersFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.BulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.BulkWithFilters.FromRawUnchecked(rawData); + public BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkWithFilters.FromRawUnchecked(rawData); } /// /// Configuration for bulk_with_filters pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.BulkWithFiltersConfig, - global::Orb.Models.Prices.BulkWithFiltersConfigFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkWithFiltersConfig : JsonModel { /// /// Property filters to apply (all must match) /// - public required IReadOnlyList Filters + public required IReadOnlyList Filters { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>( - "filters" - ); + return this._rawData.GetNotNullStruct>("filters"); } init { - this._rawData.Set>( + this._rawData.Set>( "filters", ImmutableArray.ToImmutableArray(value) ); @@ -3198,18 +3139,16 @@ public sealed record class BulkWithFiltersConfig : JsonModel /// /// Bulk tiers for rating based on total usage volume /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>( - "tiers" - ); + return this._rawData.GetNotNullStruct>("tiers"); } init { - this._rawData.Set>( + this._rawData.Set>( "tiers", ImmutableArray.ToImmutableArray(value) ); @@ -3231,10 +3170,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 +3189,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 +3198,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 +3247,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 +3266,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 +3321,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 +3340,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 +3354,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 +3375,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 +3385,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 +3416,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Prices.ConversionRateConfigConverter))] +[JsonConverter(typeof(ConversionRateConfigConverter))] public record class ConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -3529,7 +3455,7 @@ public ConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3550,7 +3476,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3570,7 +3496,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -3581,8 +3507,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3611,7 +3537,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -3622,8 +3548,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3643,13 +3569,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 +3596,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 +3607,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 @@ -3718,12 +3654,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3740,12 +3674,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3754,14 +3686,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 +3702,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 +3737,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 +3847,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 +3929,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +3990,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4059,10 +3999,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 +4020,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 +4029,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 +4052,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 +4062,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 +4082,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 +4102,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 +4171,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 +4192,8 @@ public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary - public static global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4264,18 +4201,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; @@ -4320,7 +4254,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4341,7 +4275,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4361,7 +4295,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4372,8 +4306,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4402,7 +4336,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4413,8 +4347,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4434,11 +4368,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 +4397,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 +4408,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 @@ -4511,12 +4456,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4533,12 +4476,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4547,16 +4488,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 +4504,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 +4526,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 +4649,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 +4731,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +4792,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4854,10 +4801,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 +4822,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 +4831,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 +4854,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 +4864,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 +4884,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 +4904,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 +4973,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 +4994,8 @@ public CumulativeGroupedAllocationConfig(IReadOnlyDictionary - public static global::Orb.Models.Prices.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5059,18 +5003,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; @@ -5115,7 +5056,7 @@ public CumulativeGroupedAllocationConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5136,7 +5077,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5156,7 +5097,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -5167,8 +5108,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5197,7 +5138,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -5208,8 +5149,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5229,11 +5170,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 +5199,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 +5210,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 @@ -6060,12 +5258,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6082,12 +5278,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6096,14 +5290,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 +5305,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 +5376,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 +5445,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 +5527,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +5583,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -6393,8 +5592,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 +5613,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 +5641,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 +5651,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 +5671,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 +5689,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 +5713,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 +5732,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 +5746,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; @@ -6604,7 +5798,7 @@ public PercentConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6625,7 +5819,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6645,7 +5839,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -6656,8 +5850,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6686,7 +5880,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -6697,8 +5891,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6718,11 +5912,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 +5941,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 +5952,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 @@ -6793,12 +5999,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6815,12 +6019,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6829,14 +6031,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 +6046,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 +6078,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 +6186,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 +6268,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +6329,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7131,8 +6338,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 +6359,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 +6387,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 +6397,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 +6417,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 +6435,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 +6490,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 +6509,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 +6525,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; @@ -7374,7 +6577,7 @@ public EventOutputConversionRateConfig(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7395,7 +6598,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7415,7 +6618,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -7426,8 +6629,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7456,7 +6659,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -7467,8 +6670,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7488,11 +6691,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 +6720,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 +6731,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 @@ -7563,12 +6779,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7585,12 +6799,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7599,14 +6811,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..a7e0fce99 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, @@ -159,7 +166,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static PriceEvaluateMultipleParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -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; @@ -1037,7 +1125,7 @@ public Price(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1058,7 +1146,7 @@ public bool TryPickNewFloatingUnit([NotNullWhen(true)] out NewFloatingUnitPrice? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1079,7 +1167,7 @@ public bool TryPickNewFloatingTiered([NotNullWhen(true)] out NewFloatingTieredPr /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1100,7 +1188,7 @@ public bool TryPickNewFloatingBulk([NotNullWhen(true)] out NewFloatingBulkPrice? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1121,7 +1209,7 @@ public bool TryPickBulkWithFilters([NotNullWhen(true)] out PriceBulkWithFilters? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1142,7 +1230,7 @@ public bool TryPickNewFloatingPackage([NotNullWhen(true)] out NewFloatingPackage /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1163,7 +1251,7 @@ public bool TryPickNewFloatingMatrix([NotNullWhen(true)] out NewFloatingMatrixPr /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1186,7 +1274,7 @@ public bool TryPickNewFloatingThresholdTotalAmount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1209,7 +1297,7 @@ public bool TryPickNewFloatingTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1232,7 +1320,7 @@ public bool TryPickNewFloatingTieredWithMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1255,7 +1343,7 @@ public bool TryPickNewFloatingGroupedTiered( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1278,7 +1366,7 @@ public bool TryPickNewFloatingTieredPackageWithMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1301,7 +1389,7 @@ public bool TryPickNewFloatingPackageWithAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1324,7 +1412,7 @@ public bool TryPickNewFloatingUnitWithPercent( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1347,7 +1435,7 @@ public bool TryPickNewFloatingMatrixWithAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1370,7 +1458,7 @@ public bool TryPickNewFloatingTieredWithProration( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1393,7 +1481,7 @@ public bool TryPickNewFloatingUnitWithProration( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1416,7 +1504,7 @@ public bool TryPickNewFloatingGroupedAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1439,7 +1527,7 @@ public bool TryPickNewFloatingBulkWithProration( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1462,7 +1550,7 @@ public bool TryPickNewFloatingGroupedWithProratedMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1485,7 +1573,7 @@ public bool TryPickNewFloatingGroupedWithMeteredMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1508,7 +1596,7 @@ public bool TryPickGroupedWithMinMaxThresholds( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1531,7 +1619,7 @@ public bool TryPickNewFloatingMatrixWithDisplayName( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1554,7 +1642,7 @@ public bool TryPickNewFloatingGroupedTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1577,7 +1665,7 @@ public bool TryPickNewFloatingMaxGroupTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1600,7 +1688,7 @@ public bool TryPickNewFloatingScalableMatrixWithUnitPricing( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1623,7 +1711,7 @@ public bool TryPickNewFloatingScalableMatrixWithTieredPricing( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1646,7 +1734,7 @@ public bool TryPickNewFloatingCumulativeGroupedBulk( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1665,34 +1753,11 @@ 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 . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1715,7 +1780,7 @@ public bool TryPickNewFloatingMinimumComposite( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1736,7 +1801,7 @@ public bool TryPickPercent([NotNullWhen(true)] out PricePercent? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1756,7 +1821,7 @@ public bool TryPickEventOutput([NotNullWhen(true)] out PriceEventOutput? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1767,38 +1832,37 @@ public bool TryPickEventOutput([NotNullWhen(true)] out PriceEventOutput? value) /// /// /// instance.Switch( - /// (NewFloatingUnitPrice value) => {...}, - /// (NewFloatingTieredPrice value) => {...}, - /// (NewFloatingBulkPrice value) => {...}, - /// (PriceBulkWithFilters value) => {...}, - /// (NewFloatingPackagePrice value) => {...}, - /// (NewFloatingMatrixPrice value) => {...}, - /// (NewFloatingThresholdTotalAmountPrice value) => {...}, - /// (NewFloatingTieredPackagePrice value) => {...}, - /// (NewFloatingTieredWithMinimumPrice value) => {...}, - /// (NewFloatingGroupedTieredPrice value) => {...}, - /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, - /// (NewFloatingPackageWithAllocationPrice value) => {...}, - /// (NewFloatingUnitWithPercentPrice value) => {...}, - /// (NewFloatingMatrixWithAllocationPrice value) => {...}, - /// (NewFloatingTieredWithProrationPrice value) => {...}, - /// (NewFloatingUnitWithProrationPrice value) => {...}, - /// (NewFloatingGroupedAllocationPrice value) => {...}, - /// (NewFloatingBulkWithProrationPrice value) => {...}, - /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, - /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (PriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, - /// (NewFloatingGroupedTieredPackagePrice value) => {...}, - /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, - /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (PriceCumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Prices.PriceMinimum value) => {...}, - /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (PricePercent value) => {...}, - /// (PriceEventOutput value) => {...} + /// (NewFloatingUnitPrice value) => {...}, + /// (NewFloatingTieredPrice value) => {...}, + /// (NewFloatingBulkPrice value) => {...}, + /// (PriceBulkWithFilters value) => {...}, + /// (NewFloatingPackagePrice value) => {...}, + /// (NewFloatingMatrixPrice value) => {...}, + /// (NewFloatingThresholdTotalAmountPrice value) => {...}, + /// (NewFloatingTieredPackagePrice value) => {...}, + /// (NewFloatingTieredWithMinimumPrice value) => {...}, + /// (NewFloatingGroupedTieredPrice value) => {...}, + /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, + /// (NewFloatingPackageWithAllocationPrice value) => {...}, + /// (NewFloatingUnitWithPercentPrice value) => {...}, + /// (NewFloatingMatrixWithAllocationPrice value) => {...}, + /// (NewFloatingTieredWithProrationPrice value) => {...}, + /// (NewFloatingUnitWithProrationPrice value) => {...}, + /// (NewFloatingGroupedAllocationPrice value) => {...}, + /// (NewFloatingBulkWithProrationPrice value) => {...}, + /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, + /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, + /// (PriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, + /// (NewFloatingGroupedTieredPackagePrice value) => {...}, + /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, + /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, + /// (PriceCumulativeGroupedAllocation 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; @@ -1945,7 +2005,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1956,38 +2016,37 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewFloatingUnitPrice value) => {...}, - /// (NewFloatingTieredPrice value) => {...}, - /// (NewFloatingBulkPrice value) => {...}, - /// (PriceBulkWithFilters value) => {...}, - /// (NewFloatingPackagePrice value) => {...}, - /// (NewFloatingMatrixPrice value) => {...}, - /// (NewFloatingThresholdTotalAmountPrice value) => {...}, - /// (NewFloatingTieredPackagePrice value) => {...}, - /// (NewFloatingTieredWithMinimumPrice value) => {...}, - /// (NewFloatingGroupedTieredPrice value) => {...}, - /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, - /// (NewFloatingPackageWithAllocationPrice value) => {...}, - /// (NewFloatingUnitWithPercentPrice value) => {...}, - /// (NewFloatingMatrixWithAllocationPrice value) => {...}, - /// (NewFloatingTieredWithProrationPrice value) => {...}, - /// (NewFloatingUnitWithProrationPrice value) => {...}, - /// (NewFloatingGroupedAllocationPrice value) => {...}, - /// (NewFloatingBulkWithProrationPrice value) => {...}, - /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, - /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (PriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, - /// (NewFloatingGroupedTieredPackagePrice value) => {...}, - /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, - /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (PriceCumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Prices.PriceMinimum value) => {...}, - /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (PricePercent value) => {...}, - /// (PriceEventOutput value) => {...} + /// (NewFloatingUnitPrice value) => {...}, + /// (NewFloatingTieredPrice value) => {...}, + /// (NewFloatingBulkPrice value) => {...}, + /// (PriceBulkWithFilters value) => {...}, + /// (NewFloatingPackagePrice value) => {...}, + /// (NewFloatingMatrixPrice value) => {...}, + /// (NewFloatingThresholdTotalAmountPrice value) => {...}, + /// (NewFloatingTieredPackagePrice value) => {...}, + /// (NewFloatingTieredWithMinimumPrice value) => {...}, + /// (NewFloatingGroupedTieredPrice value) => {...}, + /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, + /// (NewFloatingPackageWithAllocationPrice value) => {...}, + /// (NewFloatingUnitWithPercentPrice value) => {...}, + /// (NewFloatingMatrixWithAllocationPrice value) => {...}, + /// (NewFloatingTieredWithProrationPrice value) => {...}, + /// (NewFloatingUnitWithProrationPrice value) => {...}, + /// (NewFloatingGroupedAllocationPrice value) => {...}, + /// (NewFloatingBulkWithProrationPrice value) => {...}, + /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, + /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, + /// (PriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, + /// (NewFloatingGroupedTieredPackagePrice value) => {...}, + /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, + /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, + /// (PriceCumulativeGroupedAllocation 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 @@ -2309,12 +2357,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2331,12 +2377,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2353,12 +2397,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2375,12 +2417,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2397,12 +2437,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2419,12 +2457,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2442,12 +2478,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2464,12 +2498,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2487,12 +2519,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2509,12 +2539,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2532,12 +2560,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2555,12 +2581,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2577,12 +2601,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2600,12 +2622,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2623,12 +2643,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2646,12 +2664,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2669,12 +2685,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2692,12 +2706,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2715,12 +2727,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2738,12 +2748,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2760,12 +2768,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2783,12 +2789,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2806,12 +2810,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2829,12 +2831,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2852,12 +2852,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2875,12 +2873,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2898,12 +2894,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2920,35 +2914,10 @@ JsonSerializerOptions options ); if (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) + catch (JsonException) { // ignore } @@ -2965,12 +2934,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2984,12 +2951,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3006,12 +2971,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3020,16 +2983,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 +3220,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +3281,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -3317,8 +3290,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 +3396,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 +3483,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 +3570,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 @@ -3737,7 +3722,7 @@ public PriceBulkWithFiltersConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3758,7 +3743,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3778,7 +3763,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -3789,8 +3774,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3819,7 +3804,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -3830,8 +3815,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3880,10 +3865,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 +3876,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 @@ -3926,12 +3924,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3948,12 +3944,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4208,6 +4202,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +4263,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4264,10 +4272,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 +4447,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 @@ -4522,7 +4536,7 @@ public PriceGroupedWithMinMaxThresholdsConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4543,7 +4557,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4563,7 +4577,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4574,8 +4588,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4604,7 +4618,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4615,8 +4629,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4665,10 +4679,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 +4690,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 @@ -4711,12 +4738,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4733,12 +4758,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4993,6 +5016,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +5077,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -5049,10 +5086,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 +5261,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 @@ -5307,7 +5350,7 @@ public PriceCumulativeGroupedAllocationConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5328,7 +5371,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5348,7 +5391,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -5359,8 +5402,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5389,7 +5432,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -5400,8 +5443,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5450,10 +5493,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 +5504,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 @@ -5496,12 +5552,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5518,12 +5572,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5547,25 +5599,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); } } @@ -5597,42 +5642,42 @@ public required string ItemID } /// - /// Configuration for minimum pricing + /// The pricing model type /// - public required PriceMinimumMinimumConfig 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 PricePercentPercentConfig 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); } } /// @@ -5694,12 +5739,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Prices.PriceMinimumConversionRateConfig? ConversionRateConfig + public PricePercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5777,747 +5822,16 @@ 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 - /// by setting `metadata` to `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); } - } - - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } - - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.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); } - } - - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } - - /// - /// An alias for the price. - /// - public string? ExternalPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } - } - - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } - - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", 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); } } /// @@ -6563,6 +5877,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -6571,8 +5886,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 +6009,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) { @@ -6776,7 +6097,7 @@ public PricePercentConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6797,7 +6118,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6817,7 +6138,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -6828,8 +6149,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6858,7 +6179,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -6869,8 +6190,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6919,10 +6240,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 +6251,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 @@ -6965,12 +6299,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6987,12 +6319,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7242,6 +6572,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +6633,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7298,8 +6642,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 +6801,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) { @@ -7541,7 +6891,7 @@ public PriceEventOutputConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7562,7 +6912,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7582,7 +6932,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -7593,8 +6943,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7623,7 +6973,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -7634,8 +6984,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7684,10 +7034,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 +7045,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 @@ -7730,12 +7093,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7752,12 +7113,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } 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..7764587b0 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, @@ -162,27 +191,61 @@ IReadOnlyDictionary rawBodyData PriceEvaluateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string priceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.PriceID = priceID; } #pragma warning restore CS8618 - /// + /// public static PriceEvaluateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string priceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + priceID + ); + } + + 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) @@ -213,4 +276,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..e75d88af7 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, @@ -174,7 +181,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static PriceEvaluatePreviewEventsParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -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 @@ -1286,7 +1374,7 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPrice(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1307,7 +1395,7 @@ public bool TryPickNewFloatingUnit([NotNullWhen(true)] out NewFloatingUnitPrice? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1328,7 +1416,7 @@ public bool TryPickNewFloatingTiered([NotNullWhen(true)] out NewFloatingTieredPr /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1349,7 +1437,7 @@ public bool TryPickNewFloatingBulk([NotNullWhen(true)] out NewFloatingBulkPrice? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1373,7 +1461,7 @@ out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1394,7 +1482,7 @@ public bool TryPickNewFloatingPackage([NotNullWhen(true)] out NewFloatingPackage /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1415,7 +1503,7 @@ public bool TryPickNewFloatingMatrix([NotNullWhen(true)] out NewFloatingMatrixPr /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1438,7 +1526,7 @@ public bool TryPickNewFloatingThresholdTotalAmount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1461,7 +1549,7 @@ public bool TryPickNewFloatingTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1484,7 +1572,7 @@ public bool TryPickNewFloatingTieredWithMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1507,7 +1595,7 @@ public bool TryPickNewFloatingGroupedTiered( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1530,7 +1618,7 @@ public bool TryPickNewFloatingTieredPackageWithMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1553,7 +1641,7 @@ public bool TryPickNewFloatingPackageWithAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1576,7 +1664,7 @@ public bool TryPickNewFloatingUnitWithPercent( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1599,7 +1687,7 @@ public bool TryPickNewFloatingMatrixWithAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1622,7 +1710,7 @@ public bool TryPickNewFloatingTieredWithProration( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1645,7 +1733,7 @@ public bool TryPickNewFloatingUnitWithProration( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1668,7 +1756,7 @@ public bool TryPickNewFloatingGroupedAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1691,7 +1779,7 @@ public bool TryPickNewFloatingBulkWithProration( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1714,7 +1802,7 @@ public bool TryPickNewFloatingGroupedWithProratedMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1737,7 +1825,7 @@ public bool TryPickNewFloatingGroupedWithMeteredMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1763,7 +1851,7 @@ out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresho /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1786,7 +1874,7 @@ public bool TryPickNewFloatingMatrixWithDisplayName( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1809,7 +1897,7 @@ public bool TryPickNewFloatingGroupedTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1832,7 +1920,7 @@ public bool TryPickNewFloatingMaxGroupTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1855,7 +1943,7 @@ public bool TryPickNewFloatingScalableMatrixWithUnitPricing( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1878,7 +1966,7 @@ public bool TryPickNewFloatingScalableMatrixWithTieredPricing( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1901,7 +1989,7 @@ public bool TryPickNewFloatingCumulativeGroupedBulk( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1923,34 +2011,11 @@ 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 . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1973,7 +2038,7 @@ public bool TryPickNewFloatingMinimumComposite( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1996,7 +2061,7 @@ public bool TryPickPercent( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2019,7 +2084,7 @@ out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput? value /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2030,38 +2095,37 @@ out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput? value /// /// /// instance.Switch( - /// (NewFloatingUnitPrice value) => {...}, - /// (NewFloatingTieredPrice value) => {...}, - /// (NewFloatingBulkPrice value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters value) => {...}, - /// (NewFloatingPackagePrice value) => {...}, - /// (NewFloatingMatrixPrice value) => {...}, - /// (NewFloatingThresholdTotalAmountPrice value) => {...}, - /// (NewFloatingTieredPackagePrice value) => {...}, - /// (NewFloatingTieredWithMinimumPrice value) => {...}, - /// (NewFloatingGroupedTieredPrice value) => {...}, - /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, - /// (NewFloatingPackageWithAllocationPrice value) => {...}, - /// (NewFloatingUnitWithPercentPrice value) => {...}, - /// (NewFloatingMatrixWithAllocationPrice value) => {...}, - /// (NewFloatingTieredWithProrationPrice value) => {...}, - /// (NewFloatingUnitWithProrationPrice value) => {...}, - /// (NewFloatingGroupedAllocationPrice value) => {...}, - /// (NewFloatingBulkWithProrationPrice value) => {...}, - /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, - /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, - /// (NewFloatingGroupedTieredPackagePrice value) => {...}, - /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, - /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value) => {...}, - /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value) => {...} + /// (NewFloatingUnitPrice value) => {...}, + /// (NewFloatingTieredPrice value) => {...}, + /// (NewFloatingBulkPrice value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters value) => {...}, + /// (NewFloatingPackagePrice value) => {...}, + /// (NewFloatingMatrixPrice value) => {...}, + /// (NewFloatingThresholdTotalAmountPrice value) => {...}, + /// (NewFloatingTieredPackagePrice value) => {...}, + /// (NewFloatingTieredWithMinimumPrice value) => {...}, + /// (NewFloatingGroupedTieredPrice value) => {...}, + /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, + /// (NewFloatingPackageWithAllocationPrice value) => {...}, + /// (NewFloatingUnitWithPercentPrice value) => {...}, + /// (NewFloatingMatrixWithAllocationPrice value) => {...}, + /// (NewFloatingTieredWithProrationPrice value) => {...}, + /// (NewFloatingUnitWithProrationPrice value) => {...}, + /// (NewFloatingGroupedAllocationPrice value) => {...}, + /// (NewFloatingBulkWithProrationPrice value) => {...}, + /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, + /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, + /// (NewFloatingGroupedTieredPackagePrice value) => {...}, + /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, + /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation 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; @@ -2210,7 +2270,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2221,38 +2281,37 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewFloatingUnitPrice value) => {...}, - /// (NewFloatingTieredPrice value) => {...}, - /// (NewFloatingBulkPrice value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters value) => {...}, - /// (NewFloatingPackagePrice value) => {...}, - /// (NewFloatingMatrixPrice value) => {...}, - /// (NewFloatingThresholdTotalAmountPrice value) => {...}, - /// (NewFloatingTieredPackagePrice value) => {...}, - /// (NewFloatingTieredWithMinimumPrice value) => {...}, - /// (NewFloatingGroupedTieredPrice value) => {...}, - /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, - /// (NewFloatingPackageWithAllocationPrice value) => {...}, - /// (NewFloatingUnitWithPercentPrice value) => {...}, - /// (NewFloatingMatrixWithAllocationPrice value) => {...}, - /// (NewFloatingTieredWithProrationPrice value) => {...}, - /// (NewFloatingUnitWithProrationPrice value) => {...}, - /// (NewFloatingGroupedAllocationPrice value) => {...}, - /// (NewFloatingBulkWithProrationPrice value) => {...}, - /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, - /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, - /// (NewFloatingGroupedTieredPackagePrice value) => {...}, - /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, - /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value) => {...}, - /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value) => {...} + /// (NewFloatingUnitPrice value) => {...}, + /// (NewFloatingTieredPrice value) => {...}, + /// (NewFloatingBulkPrice value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters value) => {...}, + /// (NewFloatingPackagePrice value) => {...}, + /// (NewFloatingMatrixPrice value) => {...}, + /// (NewFloatingThresholdTotalAmountPrice value) => {...}, + /// (NewFloatingTieredPackagePrice value) => {...}, + /// (NewFloatingTieredWithMinimumPrice value) => {...}, + /// (NewFloatingGroupedTieredPrice value) => {...}, + /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, + /// (NewFloatingPackageWithAllocationPrice value) => {...}, + /// (NewFloatingUnitWithPercentPrice value) => {...}, + /// (NewFloatingMatrixWithAllocationPrice value) => {...}, + /// (NewFloatingTieredWithProrationPrice value) => {...}, + /// (NewFloatingUnitWithProrationPrice value) => {...}, + /// (NewFloatingGroupedAllocationPrice value) => {...}, + /// (NewFloatingBulkWithProrationPrice value) => {...}, + /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, + /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, + /// (NewFloatingGroupedTieredPackagePrice value) => {...}, + /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, + /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation 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 @@ -2600,12 +2694,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2622,12 +2714,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2644,12 +2734,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2667,12 +2755,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2689,12 +2775,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2711,12 +2795,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2734,12 +2816,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2756,12 +2836,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2779,12 +2857,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2801,12 +2877,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2824,12 +2898,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2847,12 +2919,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2869,12 +2939,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2892,12 +2960,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2915,12 +2981,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2938,12 +3002,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2961,12 +3023,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2984,12 +3044,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3007,12 +3065,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3030,12 +3086,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3053,12 +3107,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3076,12 +3128,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3099,12 +3149,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3122,12 +3170,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3145,12 +3191,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3168,12 +3212,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3191,12 +3233,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3214,35 +3254,10 @@ JsonSerializerOptions options ); if (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) + catch (JsonException) { // ignore } @@ -3259,12 +3274,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3282,12 +3295,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3305,12 +3316,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3572,6 +3581,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +3642,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -3628,10 +3651,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 +3767,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 +3863,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 +3959,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 @@ -4105,7 +4140,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4126,7 +4161,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4146,7 +4181,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4157,8 +4192,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4187,7 +4222,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4198,8 +4233,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4250,10 +4285,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 +4296,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 @@ -4296,12 +4344,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4318,12 +4364,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4587,6 +4631,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +4692,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4643,10 +4701,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 +4902,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 @@ -4936,7 +5000,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4957,7 +5021,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4977,7 +5041,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4988,8 +5052,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5018,7 +5082,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -5029,8 +5093,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5081,10 +5145,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 +5156,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 @@ -5127,12 +5204,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5149,12 +5224,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5418,6 +5491,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +5552,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -5474,10 +5561,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 +5762,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 @@ -5767,7 +5860,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5788,7 +5881,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5808,7 +5901,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -5819,8 +5912,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5849,7 +5942,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -5860,8 +5953,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5912,10 +6005,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 +6016,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 @@ -5958,12 +6064,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5980,12 +6084,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6013,25 +6115,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 +6166,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 +6265,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 +6347,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +6387,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 +6403,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 +6439,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum FromRawUnchecked( + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6329,20 +6448,20 @@ IReadOnlyDictionary rawData } } -class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumFromRaw - : IFromRawJson +class PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentFromRaw + : IFromRawJson { /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum FromRawUnchecked( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent FromRawUnchecked( IReadOnlyDictionary rawData - ) => PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum.FromRawUnchecked(rawData); + ) => PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadenceConverter))] -public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence +[JsonConverter(typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadenceConverter))] +public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadence { Annual, SemiAnnual, @@ -6352,807 +6471,10 @@ public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence Custom, } -sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadenceConverter - : JsonConverter +sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadenceConverter + : 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); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadenceConverter))] -public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadenceConverter - : JsonConverter -{ - public override PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadence Read( + public override PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7237,10 +6559,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 @@ -7337,7 +6662,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7358,7 +6683,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7378,7 +6703,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -7389,8 +6714,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7419,7 +6744,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -7430,8 +6755,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7482,10 +6807,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 +6818,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 @@ -7528,12 +6866,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7550,12 +6886,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7819,6 +7153,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +7214,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7875,10 +7223,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 +7406,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 @@ -8157,7 +7511,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8178,7 +7532,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8198,7 +7552,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -8209,8 +7563,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8239,7 +7593,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -8250,8 +7604,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8302,10 +7656,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 +7667,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 @@ -8348,12 +7715,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8370,12 +7735,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } 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..0e2e6fa2a 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, @@ -36,24 +43,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] PriceFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string priceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.PriceID = priceID; } #pragma warning restore CS8618 - /// + /// public static PriceFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string priceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + priceID + ); + } + + 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) @@ -74,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/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..d574e3eea 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, @@ -74,7 +81,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static PriceListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -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..051e8411e 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, @@ -72,27 +79,61 @@ IReadOnlyDictionary rawBodyData PriceUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string priceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.PriceID = priceID; } #pragma warning restore CS8618 - /// + /// public static PriceUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string priceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + priceID + ); + } + + 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) @@ -122,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/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..93c2c46b3 100644 --- a/src/Orb/Models/SharedDiscount.cs +++ b/src/Orb/Models/SharedDiscount.cs @@ -71,7 +71,7 @@ public SharedDiscount(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -92,7 +92,7 @@ public bool TryPickPercentage([NotNullWhen(true)] out PercentageDiscount? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -113,7 +113,7 @@ public bool TryPickTrial([NotNullWhen(true)] out TrialDiscount? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -134,7 +134,7 @@ public bool TryPickUsage([NotNullWhen(true)] out UsageDiscount? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -154,7 +154,7 @@ public bool TryPickAmount([NotNullWhen(true)] out AmountDiscount? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -165,10 +165,10 @@ public bool TryPickAmount([NotNullWhen(true)] out AmountDiscount? value) /// /// /// instance.Switch( - /// (PercentageDiscount value) => {...}, - /// (TrialDiscount value) => {...}, - /// (UsageDiscount value) => {...}, - /// (AmountDiscount value) => {...} + /// (PercentageDiscount value) => {...}, + /// (TrialDiscount value) => {...}, + /// (UsageDiscount value) => {...}, + /// (AmountDiscount value) => {...} /// ); /// /// @@ -205,7 +205,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -216,10 +216,10 @@ public void Switch( /// /// /// var result = instance.Match( - /// (PercentageDiscount value) => {...}, - /// (TrialDiscount value) => {...}, - /// (UsageDiscount value) => {...}, - /// (AmountDiscount value) => {...} + /// (PercentageDiscount value) => {...}, + /// (TrialDiscount value) => {...}, + /// (UsageDiscount value) => {...}, + /// (AmountDiscount value) => {...} /// ); /// /// @@ -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 @@ -320,12 +335,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -339,12 +352,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -358,12 +369,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -377,12 +386,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } 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..c62ff18d8 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" @@ -626,7 +629,7 @@ public DiscountInterval(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -647,7 +650,7 @@ public bool TryPickAmount([NotNullWhen(true)] out AmountDiscountInterval? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -668,7 +671,7 @@ public bool TryPickPercentage([NotNullWhen(true)] out PercentageDiscountInterval /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -688,7 +691,7 @@ public bool TryPickUsage([NotNullWhen(true)] out UsageDiscountInterval? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -699,9 +702,9 @@ public bool TryPickUsage([NotNullWhen(true)] out UsageDiscountInterval? value) /// /// /// instance.Switch( - /// (AmountDiscountInterval value) => {...}, - /// (PercentageDiscountInterval value) => {...}, - /// (UsageDiscountInterval value) => {...} + /// (AmountDiscountInterval value) => {...}, + /// (PercentageDiscountInterval value) => {...}, + /// (UsageDiscountInterval value) => {...} /// ); /// /// @@ -734,7 +737,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -745,9 +748,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (AmountDiscountInterval value) => {...}, - /// (PercentageDiscountInterval value) => {...}, - /// (UsageDiscountInterval value) => {...} + /// (AmountDiscountInterval value) => {...}, + /// (PercentageDiscountInterval value) => {...}, + /// (UsageDiscountInterval value) => {...} /// ); /// /// @@ -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 @@ -844,12 +861,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -866,12 +881,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -888,12 +901,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/SubscriptionChanges/SubscriptionChangeApplyParams.cs b/src/Orb/Models/SubscriptionChanges/SubscriptionChangeApplyParams.cs index 3c67a0f9c..8b8cc4701 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, @@ -134,27 +141,66 @@ IReadOnlyDictionary rawBodyData SubscriptionChangeApplyParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string subscriptionChangeID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.SubscriptionChangeID = subscriptionChangeID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionChangeApplyParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string subscriptionChangeID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + subscriptionChangeID + ); + } + + 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) @@ -185,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/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..14c9261dc 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, @@ -40,24 +47,61 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] SubscriptionChangeCancelParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string subscriptionChangeID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.SubscriptionChangeID = subscriptionChangeID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionChangeCancelParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string subscriptionChangeID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + subscriptionChangeID + ); + } + + 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) @@ -79,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/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..bed07db2f 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, @@ -110,7 +115,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static SubscriptionChangeListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -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..4c3342501 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, @@ -44,26 +51,63 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] SubscriptionChangeRetrieveParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string subscriptionChangeID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.SubscriptionChangeID = subscriptionChangeID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionChangeRetrieveParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string subscriptionChangeID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + subscriptionChangeID ); } + 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 +127,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..d0faf924b 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)) ), @@ -480,7 +495,7 @@ public NewSubscriptionBulkPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -501,7 +516,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -521,7 +536,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -532,8 +547,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -562,7 +577,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -573,8 +588,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig 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 @@ -669,12 +697,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -691,12 +717,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionBulkWithProrationPrice.cs index dab88d879..312fb9e42 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) { @@ -661,7 +676,7 @@ public NewSubscriptionBulkWithProrationPriceConversionRateConfig(JsonElement ele /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -682,7 +697,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -702,7 +717,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -713,8 +728,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -743,7 +758,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -754,8 +769,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -850,12 +878,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -872,12 +898,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionCumulativeGroupedBulkPrice.cs index fbc2978a4..302a40aea 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); } /// @@ -677,7 +686,7 @@ public NewSubscriptionCumulativeGroupedBulkPriceConversionRateConfig(JsonElement /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -698,7 +707,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -718,7 +727,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -729,8 +738,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -759,7 +768,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -770,8 +779,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -866,12 +890,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -888,12 +910,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedAllocationPrice.cs index 7d50e2604..fde587816 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); } /// @@ -587,7 +599,7 @@ public NewSubscriptionGroupedAllocationPriceConversionRateConfig(JsonElement ele /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -608,7 +620,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -628,7 +640,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -639,8 +651,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -669,7 +681,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -680,8 +692,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -776,12 +801,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -798,12 +821,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPackagePrice.cs index cf6893503..e655a1d0f 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); } /// @@ -677,7 +694,7 @@ public NewSubscriptionGroupedTieredPackagePriceConversionRateConfig(JsonElement /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -698,7 +715,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -718,7 +735,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -729,8 +746,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -759,7 +776,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -770,8 +787,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -866,12 +898,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -888,12 +918,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedTieredPrice.cs index 3f6744267..c0f42c780 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); } /// @@ -660,7 +663,7 @@ public NewSubscriptionGroupedTieredPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -681,7 +684,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -701,7 +704,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -712,8 +715,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -742,7 +745,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -753,8 +756,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -849,12 +865,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -871,12 +885,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithMeteredMinimumPrice.cs index 42f095046..230562982 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); } /// @@ -808,7 +813,7 @@ public NewSubscriptionGroupedWithMeteredMinimumPriceConversionRateConfig(JsonEle /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -829,7 +834,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -849,7 +854,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -860,8 +865,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -890,7 +895,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -901,8 +906,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -999,12 +1017,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1021,12 +1037,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionGroupedWithProratedMinimumPrice.cs index 77d37738f..224b1e173 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); } /// @@ -593,7 +611,7 @@ public NewSubscriptionGroupedWithProratedMinimumPriceConversionRateConfig(JsonEl /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -614,7 +632,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -634,7 +652,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -645,8 +663,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -675,7 +693,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -686,8 +704,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -784,12 +815,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -806,12 +835,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixPrice.cs index d505ad247..cc22d7b26 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) { @@ -481,7 +498,7 @@ public NewSubscriptionMatrixPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -502,7 +519,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -522,7 +539,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -533,8 +550,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -563,7 +580,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -574,8 +591,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -670,12 +700,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -692,12 +720,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithAllocationPrice.cs index a507d2ac1..dd1044ad9 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 @@ -493,7 +510,7 @@ public NewSubscriptionMatrixWithAllocationPriceConversionRateConfig(JsonElement /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -514,7 +531,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -534,7 +551,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -545,8 +562,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -575,7 +592,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -586,8 +603,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -682,12 +714,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -704,12 +734,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMatrixWithDisplayNamePrice.cs index 6f2c58806..f67947860 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); } /// @@ -685,7 +700,7 @@ public NewSubscriptionMatrixWithDisplayNamePriceConversionRateConfig(JsonElement /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -706,7 +721,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -726,7 +741,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -737,8 +752,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -767,7 +782,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -778,8 +793,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -874,12 +904,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -896,12 +924,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMaxGroupTieredPackagePrice.cs index c9ee665e1..f7ba7d5c5 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); } /// @@ -676,7 +693,7 @@ public NewSubscriptionMaxGroupTieredPackagePriceConversionRateConfig(JsonElement /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -697,7 +714,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -717,7 +734,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -728,8 +745,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -758,7 +775,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -769,8 +786,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -865,12 +897,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -887,12 +917,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionMinimumCompositePrice.cs index 7b742fcad..4640ebe8d 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); } /// @@ -587,7 +599,7 @@ public NewSubscriptionMinimumCompositePriceConversionRateConfig(JsonElement elem /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -608,7 +620,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -628,7 +640,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -639,8 +651,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -669,7 +681,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -680,8 +692,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -776,12 +801,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -798,12 +821,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionPackagePrice.cs index 7d15cb98a..ac734de94 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) { @@ -481,7 +498,7 @@ public NewSubscriptionPackagePriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -502,7 +519,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -522,7 +539,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -533,8 +550,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -563,7 +580,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -574,8 +591,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -670,12 +700,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -692,12 +720,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionPackageWithAllocationPrice.cs index f82c1228b..483c4343c 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))] @@ -580,7 +594,7 @@ public NewSubscriptionPackageWithAllocationPriceConversionRateConfig(JsonElement /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -601,7 +615,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -621,7 +635,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -632,8 +646,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -662,7 +676,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -673,8 +687,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -769,12 +798,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -791,12 +818,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithTieredPricingPrice.cs index 7e390a378..1205e2332 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( @@ -807,7 +819,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -828,7 +840,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -848,7 +860,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -859,8 +871,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -889,7 +901,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -900,8 +912,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -998,12 +1023,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1020,12 +1043,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionScalableMatrixWithUnitPricingPrice.cs index 369b5f6fa..4e176eb7f 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( @@ -737,7 +767,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -758,7 +788,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -778,7 +808,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -789,8 +819,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -819,7 +849,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -830,8 +860,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -928,12 +971,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -950,12 +991,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionThresholdTotalAmountPrice.cs index 8b368dc93..b96509713 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))] @@ -673,7 +682,7 @@ public NewSubscriptionThresholdTotalAmountPriceConversionRateConfig(JsonElement /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -694,7 +703,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -714,7 +723,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -725,8 +734,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -755,7 +764,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -766,8 +775,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -862,12 +886,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -884,12 +906,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackagePrice.cs index b343c95c3..e06097965 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))] @@ -660,7 +663,7 @@ public NewSubscriptionTieredPackagePriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -681,7 +684,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -701,7 +704,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -712,8 +715,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -742,7 +745,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -753,8 +756,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -849,12 +865,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -871,12 +885,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPackageWithMinimumPrice.cs index b279882c4..fa1c07b3d 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))] @@ -674,7 +693,7 @@ public NewSubscriptionTieredPackageWithMinimumPriceConversionRateConfig(JsonElem /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -695,7 +714,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -715,7 +734,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -726,8 +745,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -756,7 +775,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -767,8 +786,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -865,12 +897,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -887,12 +917,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredPrice.cs index d3dbefc1d..f5997159a 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) { @@ -481,7 +498,7 @@ public NewSubscriptionTieredPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -502,7 +519,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -522,7 +539,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -533,8 +550,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -563,7 +580,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -574,8 +591,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -670,12 +700,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -692,12 +720,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionTieredWithMinimumPrice.cs index 9cfb82003..57048f364 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))] @@ -714,7 +722,7 @@ public NewSubscriptionTieredWithMinimumPriceConversionRateConfig(JsonElement ele /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -735,7 +743,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -755,7 +763,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -766,8 +774,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -796,7 +804,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -807,8 +815,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -903,12 +924,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -925,12 +944,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitPrice.cs index 5d518a9cb..9487130e6 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) { @@ -481,7 +498,7 @@ public NewSubscriptionUnitPriceConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -502,7 +519,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -522,7 +539,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -533,8 +550,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -563,7 +580,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -574,8 +591,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -670,12 +700,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -692,12 +720,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithPercentPrice.cs index 76992d4a8..6fbcda9f3 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))] @@ -570,7 +580,7 @@ public NewSubscriptionUnitWithPercentPriceConversionRateConfig(JsonElement eleme /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -591,7 +601,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -611,7 +621,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -622,8 +632,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -652,7 +662,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -663,8 +673,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -759,12 +782,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -781,12 +802,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs b/src/Orb/Models/Subscriptions/NewSubscriptionUnitWithProrationPrice.cs index 2a11c3c49..e4ad9031d 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))] @@ -566,7 +578,7 @@ public NewSubscriptionUnitWithProrationPriceConversionRateConfig(JsonElement ele /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -587,7 +599,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -607,7 +619,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -618,8 +630,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -648,7 +660,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -659,8 +671,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -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 @@ -755,12 +780,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -777,12 +800,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/Subscription.cs b/src/Orb/Models/Subscriptions/Subscription.cs index d98cab13e..9e790cc74 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" @@ -625,7 +628,7 @@ public DiscountInterval(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -646,7 +649,7 @@ public bool TryPickAmount([NotNullWhen(true)] out AmountDiscountInterval? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -667,7 +670,7 @@ public bool TryPickPercentage([NotNullWhen(true)] out PercentageDiscountInterval /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -687,7 +690,7 @@ public bool TryPickUsage([NotNullWhen(true)] out UsageDiscountInterval? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -698,9 +701,9 @@ public bool TryPickUsage([NotNullWhen(true)] out UsageDiscountInterval? value) /// /// /// instance.Switch( - /// (AmountDiscountInterval value) => {...}, - /// (PercentageDiscountInterval value) => {...}, - /// (UsageDiscountInterval value) => {...} + /// (AmountDiscountInterval value) => {...}, + /// (PercentageDiscountInterval value) => {...}, + /// (UsageDiscountInterval value) => {...} /// ); /// /// @@ -733,7 +736,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -744,9 +747,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (AmountDiscountInterval value) => {...}, - /// (PercentageDiscountInterval value) => {...}, - /// (UsageDiscountInterval value) => {...} + /// (AmountDiscountInterval value) => {...}, + /// (PercentageDiscountInterval value) => {...}, + /// (UsageDiscountInterval value) => {...} /// ); /// /// @@ -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 @@ -843,12 +860,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -865,12 +880,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -887,12 +900,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/SubscriptionCancelParams.cs b/src/Orb/Models/Subscriptions/SubscriptionCancelParams.cs index 7308e5a0d..fc9ef127f 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, @@ -143,27 +150,61 @@ IReadOnlyDictionary rawBodyData SubscriptionCancelParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionCancelParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + subscriptionID + ); + } + + 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) @@ -194,6 +235,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..deb920cb5 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs @@ -47,9 +47,9 @@ namespace Orb.Models.Subscriptions; /// the subscription being created. This is useful when a customer has prices that /// differ from the default prices for a specific plan. /// -/// This feature is only available for accounts that have migrated to -/// Subscription Overrides Version 2. You can find your Subscription Overrides Version -/// at the bottom of your [Plans page](https://app.withorb.com/plans) +/// <Note> This feature is only available for accounts that have migrated +/// to Subscription Overrides Version 2. You can find your Subscription Overrides +/// Version at the bottom of your [Plans page](https://app.withorb.com/plans) </Note> /// /// ### Adding Prices /// @@ -139,8 +139,8 @@ namespace Orb.Models.Subscriptions; /// /// ## Price overrides (DEPRECATED) /// -/// Price overrides are being phased out in favor adding/removing/replacing -/// prices. (See [Customize your customer's subscriptions](/api-reference/subscription/create-subscription)) +/// <Note> Price overrides are being phased out in favor adding/removing/replacing +/// prices. (See [Customize your customer's subscriptions](/api-reference/subscription/create-subscription)) </Note> /// /// Price overrides are used to update some or all prices in a plan for the /// specific subscription being created. This is useful when a new customer has negotiated @@ -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, @@ -765,7 +772,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static SubscriptionCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -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; @@ -1002,7 +1043,7 @@ public Adjustment(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1023,7 +1064,7 @@ public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDi /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1044,7 +1085,7 @@ public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1065,7 +1106,7 @@ public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1086,7 +1127,7 @@ public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1106,7 +1147,7 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1117,11 +1158,11 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// @@ -1160,7 +1201,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1171,11 +1212,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// @@ -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 @@ -1287,12 +1336,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1309,12 +1356,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1331,12 +1376,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1350,12 +1393,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1369,12 +1410,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1383,14 +1422,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 +1516,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 +1569,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 +1618,7 @@ public override void Validate() _ = this.EndDate; _ = this.ExternalPriceID; _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; _ = this.MinimumAmount; _ = this.PlanPhaseOrder; this.Price?.Validate(); @@ -1566,8 +1628,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 +1664,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 +1715,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 +1755,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 +1795,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 +1835,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 +1875,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 +1915,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 +1955,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 +1997,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 +2037,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 +2077,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 +2117,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 +2158,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 +2165,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 +2238,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 +2263,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 +2329,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 +2365,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 +2413,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 +2425,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; @@ -2372,7 +2446,7 @@ public Price(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2393,7 +2467,7 @@ public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUn /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2416,7 +2490,7 @@ public bool TryPickNewSubscriptionTiered( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2435,24 +2509,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. + /// 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; } @@ -2460,7 +2532,7 @@ public bool TryPickBulkWithFilters( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2483,7 +2555,7 @@ public bool TryPickNewSubscriptionPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2506,7 +2578,7 @@ public bool TryPickNewSubscriptionMatrix( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2529,7 +2601,7 @@ public bool TryPickNewSubscriptionThresholdTotalAmount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2552,7 +2624,7 @@ public bool TryPickNewSubscriptionTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2575,7 +2647,7 @@ public bool TryPickNewSubscriptionTieredWithMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2598,7 +2670,7 @@ public bool TryPickNewSubscriptionGroupedTiered( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2621,7 +2693,7 @@ public bool TryPickNewSubscriptionTieredPackageWithMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2644,7 +2716,7 @@ public bool TryPickNewSubscriptionPackageWithAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2667,7 +2739,7 @@ public bool TryPickNewSubscriptionUnitWithPercent( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2688,24 +2760,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. + /// 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; } @@ -2713,7 +2783,7 @@ public bool TryPickTieredWithProration( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2736,7 +2806,7 @@ public bool TryPickNewSubscriptionUnitWithProration( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2759,7 +2829,7 @@ public bool TryPickNewSubscriptionGroupedAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2782,7 +2852,7 @@ public bool TryPickNewSubscriptionBulkWithProration( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2805,7 +2875,7 @@ public bool TryPickNewSubscriptionGroupedWithProratedMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2826,24 +2896,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. + /// 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; } @@ -2851,7 +2921,7 @@ public bool TryPickGroupedWithMinMaxThresholds( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2874,7 +2944,7 @@ public bool TryPickNewSubscriptionMatrixWithDisplayName( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2897,7 +2967,7 @@ public bool TryPickNewSubscriptionGroupedTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2920,7 +2990,7 @@ public bool TryPickNewSubscriptionMaxGroupTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2943,7 +3013,7 @@ public bool TryPickNewSubscriptionScalableMatrixWithUnitPricing( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2966,7 +3036,7 @@ public bool TryPickNewSubscriptionScalableMatrixWithTieredPricing( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2987,47 +3057,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. + /// 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; } @@ -3035,7 +3082,7 @@ public bool TryPickMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3056,54 +3103,50 @@ 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. + /// 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. + /// 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; } /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -3114,38 +3157,37 @@ public bool TryPickEventOutput( /// /// /// instance.Switch( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.BulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.TieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.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) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Subscriptions.Percent value) => {...}, - /// (global::Orb.Models.Subscriptions.EventOutput value) => {...} + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (BulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (TieredWithProration value) => {...}, + /// (NewSubscriptionUnitWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedAllocationPrice value) => {...}, + /// (NewSubscriptionBulkWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, + /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, + /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -3154,7 +3196,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 +3207,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 +3237,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 +3270,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 +3288,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 +3309,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: @@ -3292,7 +3330,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -3303,38 +3341,37 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.BulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.TieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.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) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Subscriptions.Percent value) => {...}, - /// (global::Orb.Models.Subscriptions.EventOutput value) => {...} + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (BulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (TieredWithProration value) => {...}, + /// (NewSubscriptionUnitWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedAllocationPrice value) => {...}, + /// (NewSubscriptionBulkWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, + /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, + /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -3343,7 +3380,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 +3403,7 @@ public T Match( NewSubscriptionMatrixWithAllocationPrice, T > newSubscriptionMatrixWithAllocation, - System::Func tieredWithProration, + System::Func tieredWithProration, System::Func newSubscriptionUnitWithProration, System::Func newSubscriptionGroupedAllocation, System::Func newSubscriptionBulkWithProration, @@ -3378,10 +3415,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 +3440,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 +3451,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 +3469,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 +3477,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 +3494,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 +3636,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 +3653,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 @@ -3711,12 +3729,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3733,12 +3749,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3755,12 +3769,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3771,19 +3783,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3800,12 +3809,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3822,12 +3829,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3845,12 +3850,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3868,12 +3871,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3891,12 +3892,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3914,12 +3913,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3937,12 +3934,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3960,12 +3955,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3983,12 +3976,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4006,12 +3997,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4022,19 +4011,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4052,12 +4038,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4075,12 +4059,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4098,12 +4080,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4121,12 +4101,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4144,12 +4122,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4160,19 +4136,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4190,12 +4163,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4213,12 +4184,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4236,12 +4205,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4259,12 +4226,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4282,12 +4247,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4305,12 +4268,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4321,42 +4282,16 @@ 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(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4374,12 +4309,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4390,19 +4323,13 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4413,19 +4340,13 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4434,40 +4355,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 +4385,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 +4493,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,18 +4588,31 @@ 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 - /// by setting `metadata` to `null`. + /// The ID of the license type to associate with this price. /// - public IReadOnlyDictionary? Metadata + public string? LicenseTypeID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); + return this._rawData.GetNullableClass("license_type_id"); } - init + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init { this._rawData.Set?>( "metadata", @@ -4743,6 +4662,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -4752,8 +4672,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 +4693,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 +4735,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 +4766,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 +4785,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 +4794,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 +4843,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 +4862,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 +4917,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 +4936,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 +4950,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 +4971,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 +4981,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 +5012,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Subscriptions.ConversionRateConfigConverter))] +[JsonConverter(typeof(ConversionRateConfigConverter))] public record class ConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5154,7 +5051,7 @@ public ConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5175,7 +5072,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5195,7 +5092,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -5206,8 +5103,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5236,7 +5133,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -5247,8 +5144,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5268,13 +5165,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 +5192,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 +5203,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 @@ -5343,12 +5250,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5365,12 +5270,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5379,14 +5282,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 +5297,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 +5357,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 +5428,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 +5524,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +5599,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -5700,10 +5609,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 +5630,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 +5639,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 +5660,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 +5670,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 +5690,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 +5709,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 +5717,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 +5746,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 +5765,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 +5774,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 +5832,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 +5853,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 +5862,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; @@ -6017,7 +5915,7 @@ public TieredWithProrationConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6038,7 +5936,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6058,7 +5956,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -6069,8 +5967,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6099,7 +5997,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -6110,8 +6008,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6131,11 +6029,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 +6058,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 +6069,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 @@ -6208,12 +6117,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6230,12 +6137,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6244,16 +6149,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 +6165,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 +6187,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 +6297,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 +6393,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +6468,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -6567,10 +6478,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 +6499,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 +6508,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 +6531,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 +6541,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 +6561,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 +6581,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 +6650,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 +6671,8 @@ public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6790,21 +6680,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; @@ -6849,7 +6733,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6870,7 +6754,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6890,7 +6774,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -6901,8 +6785,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6931,7 +6815,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -6942,8 +6826,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6963,11 +6847,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 +6876,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 +6887,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 @@ -7040,12 +6935,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7062,12 +6955,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7076,16 +6967,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 +6983,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 +7005,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 +7115,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 +7211,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +7286,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -7399,10 +7296,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 +7317,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 +7326,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 +7349,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 +7359,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 +7379,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 +7399,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 +7468,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 +7489,8 @@ public CumulativeGroupedAllocationConfig(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7622,21 +7498,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; @@ -7681,7 +7551,7 @@ public CumulativeGroupedAllocationConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7702,7 +7572,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7722,7 +7592,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -7733,8 +7603,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7763,7 +7633,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -7774,8 +7644,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7795,11 +7665,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 +7694,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 +7705,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 @@ -7872,12 +7753,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7894,12 +7773,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7908,16 +7785,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 +7800,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 +7830,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 +7927,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 +8023,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +8076,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 +8093,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 +8152,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 +8162,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 +8182,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 +8198,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 +8282,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8436,7 +8291,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public PercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8445,7 +8300,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public PercentConversionRateConfig(JsonElement element) { this._element = element; } @@ -8454,7 +8309,7 @@ public MinimumConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8475,7 +8330,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8495,7 +8350,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -8506,8 +8361,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8527,7 +8382,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" ); } } @@ -8536,7 +8391,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -8547,8 +8402,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8563,16 +8418,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 +8446,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 +8463,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 @@ -8642,12 +8510,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8664,12 +8530,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8678,14 +8542,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 +8557,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 +8625,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 +8684,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 +8780,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +8832,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 +8855,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 +8914,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 +8924,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 +8944,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 +8960,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 +9045,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 +9077,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public EventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9185,7 +9086,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public EventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9194,7 +9095,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public EventOutputConversionRateConfig(JsonElement element) { this._element = element; } @@ -9203,7 +9104,7 @@ public PercentConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9224,7 +9125,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9244,7 +9145,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -9255,8 +9156,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9276,7 +9177,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" ); } } @@ -9285,7 +9186,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -9296,8 +9197,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9312,16 +9213,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 +9241,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 +9258,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 @@ -9392,12 +9306,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9414,12 +9326,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9428,14 +9338,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 +9353,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 + public override void Write( + Utf8JsonWriter writer, + ExternalMarketplace value, + JsonSerializerOptions options + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "event_output_config" - ); - } - init { this._rawData.Set("event_output_config", value); } + JsonSerializer.Serialize( + writer, + value switch + { + ExternalMarketplace.Google => "google", + ExternalMarketplace.Aws => "aws", + ExternalMarketplace.Azure => "azure", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); } +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemoveAdjustment : JsonModel +{ /// - /// The id of the item the price will be associated with. + /// The id of the adjustment to remove on the subscription. /// - public required string ItemID + public required string AdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass("adjustment_id"); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("adjustment_id", value); } } - /// - /// The pricing model type - /// - public JsonElement ModelType + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } + _ = this.AdjustmentID; } - /// - /// The name of the price. - /// - public required string Name + public RemoveAdjustment() { } + +#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,264 +9604,206 @@ 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. + /// 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. + /// 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; } /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -10041,28 +9814,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" ); } } @@ -10071,7 +9859,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -10082,34 +9870,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 +9928,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,69 +9951,134 @@ 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 ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } return new(element); } - case "tiered": + case "usage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "maximum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) { // ignore } @@ -10216,16 +10087,14 @@ JsonSerializerOptions options } 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,122 +10102,58 @@ JsonSerializerOptions options } } -[System::Obsolete("deprecated")] -[JsonConverter(typeof(ExternalMarketplaceConverter))] -public enum ExternalMarketplace -{ - Google, - Aws, - Azure, -} - -sealed class ExternalMarketplaceConverter : JsonConverter +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ReplacePrice : JsonModel { - public override ExternalMarketplace Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + /// The id of the price on the plan to replace in the subscription. + /// + public required string ReplacesPriceID { - return JsonSerializer.Deserialize(ref reader, options) switch + get { - "google" => ExternalMarketplace.Google, - "aws" => ExternalMarketplace.Aws, - "azure" => ExternalMarketplace.Azure, - _ => (ExternalMarketplace)(-1), - }; + 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 - ) - { - 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 adjustment to remove on the subscription. + /// The definition of a new allocation price to create and add to the subscription. /// - public required string AdjustmentID + public NewAllocationPrice? AllocationPrice { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment_id"); + return this._rawData.GetNullableClass("allocation_price"); } - init { this._rawData.Set("adjustment_id", value); } - } - - /// - public override void Validate() - { - _ = this.AdjustmentID; - } - - public RemoveAdjustment() { } - - public RemoveAdjustment(RemoveAdjustment removeAdjustment) - : base(removeAdjustment) { } - - public RemoveAdjustment(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveAdjustment(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + init { this._rawData.Set("allocation_price", value); } } - [SetsRequiredMembers] - public RemoveAdjustment(string adjustmentID) - : this() + /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for + /// the replacement price. + /// + [System::Obsolete("deprecated")] + public IReadOnlyList? Discounts { - this.AdjustmentID = adjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("discounts"); + } + init + { + this._rawData.Set?>( + "discounts", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } } -} - -class RemoveAdjustmentFromRaw : IFromRawJson -{ - /// - public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => - RemoveAdjustment.FromRawUnchecked(rawData); -} -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemovePrice : JsonModel -{ /// - /// The external price id of the price to remove on the subscription. + /// The external price id of the price to add to the subscription. /// public string? ExternalPriceID { @@ -10361,132 +10166,161 @@ public string? ExternalPriceID } /// - /// The id of the price to remove on the subscription. + /// The new quantity of the price, if the price is a fixed price. /// - public string? PriceID + public double? FixedPriceQuantity { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price_id"); + return this._rawData.GetNullableStruct("fixed_price_quantity"); } - init { this._rawData.Set("price_id", value); } - } - - /// - public override void Validate() - { - _ = this.ExternalPriceID; - _ = this.PriceID; + init { this._rawData.Set("fixed_price_quantity", value); } } - public RemovePrice() { } - - public RemovePrice(RemovePrice removePrice) - : base(removePrice) { } - - public RemovePrice(IReadOnlyDictionary 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 disable CS8618 - [SetsRequiredMembers] - RemovePrice(FrozenDictionary rawData) + /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values. + /// + public IReadOnlyDictionary? MetricParameterOverrides { - this._rawData = new(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) + ); + } } -#pragma warning restore CS8618 - /// - public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) + /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount + /// for the replacement price. + /// + [System::Obsolete("deprecated")] + public string? MinimumAmount { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", value); } } -} - -class RemovePriceFromRaw : IFromRawJson -{ - /// - public RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) => - RemovePrice.FromRawUnchecked(rawData); -} -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class ReplaceAdjustment : JsonModel -{ /// - /// The definition of a new adjustment to create and add to the subscription. + /// New subscription price request body params. /// - public required ReplaceAdjustmentAdjustment Adjustment + public ReplacePricePrice? Price { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment"); + return this._rawData.GetNullableClass("price"); } - init { this._rawData.Set("adjustment", value); } + init { this._rawData.Set("price", value); } } /// - /// The id of the adjustment on the plan to replace in the subscription. + /// The id of the price to add to the subscription. /// - public required string ReplacesAdjustmentID + public string? PriceID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); + return this._rawData.GetNullableClass("price_id"); } - init { this._rawData.Set("replaces_adjustment_id", value); } + init { this._rawData.Set("price_id", value); } } /// public override void Validate() { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; + _ = this.ReplacesPriceID; + this.AllocationPrice?.Validate(); + foreach (var item in this.Discounts ?? []) + { + item.Validate(); + } + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; + _ = this.MinimumAmount; + this.Price?.Validate(); + _ = this.PriceID; } - public ReplaceAdjustment() { } + public ReplacePrice() { } - public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) - : base(replaceAdjustment) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePrice(ReplacePrice replacePrice) + : base(replacePrice) { } +#pragma warning restore CS8618 - public ReplaceAdjustment(IReadOnlyDictionary rawData) + public ReplacePrice(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplaceAdjustment(FrozenDictionary rawData) + ReplacePrice(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public ReplacePrice(string replacesPriceID) + : this() + { + this.ReplacesPriceID = replacesPriceID; + } } -class ReplaceAdjustmentFromRaw : IFromRawJson +class ReplacePriceFromRaw : IFromRawJson { /// - public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => - ReplaceAdjustment.FromRawUnchecked(rawData); + public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplacePrice.FromRawUnchecked(rawData); } /// -/// The definition of a new adjustment to create and add to the subscription. +/// New subscription price request body params. /// -[JsonConverter(typeof(ReplaceAdjustmentAdjustmentConverter))] -public record class ReplaceAdjustmentAdjustment : ModelBase +[JsonConverter(typeof(ReplacePricePriceConverter))] +public record class ReplacePricePrice : ModelBase { public object? Value { get; } = null; @@ -10503,4472 +10337,2776 @@ public JsonElement Json } } - public string? Currency + public string ItemID { get { - return Match( - newPercentageDiscount: (x) => x.Currency, - newUsageDiscount: (x) => x.Currency, - newAmountDiscount: (x) => x.Currency, - newMinimum: (x) => x.Currency, - newMaximum: (x) => x.Currency - ); - } - } - - public bool? IsInvoiceLevel - { - get - { - return Match( - newPercentageDiscount: (x) => x.IsInvoiceLevel, - newUsageDiscount: (x) => x.IsInvoiceLevel, - newAmountDiscount: (x) => x.IsInvoiceLevel, - newMinimum: (x) => x.IsInvoiceLevel, - newMaximum: (x) => x.IsInvoiceLevel + return Match( + newSubscriptionUnit: (x) => x.ItemID, + newSubscriptionTiered: (x) => x.ItemID, + newSubscriptionBulk: (x) => x.ItemID, + bulkWithFilters: (x) => x.ItemID, + newSubscriptionPackage: (x) => x.ItemID, + newSubscriptionMatrix: (x) => x.ItemID, + newSubscriptionThresholdTotalAmount: (x) => x.ItemID, + newSubscriptionTieredPackage: (x) => x.ItemID, + newSubscriptionTieredWithMinimum: (x) => x.ItemID, + newSubscriptionGroupedTiered: (x) => x.ItemID, + newSubscriptionTieredPackageWithMinimum: (x) => x.ItemID, + newSubscriptionPackageWithAllocation: (x) => x.ItemID, + newSubscriptionUnitWithPercent: (x) => x.ItemID, + newSubscriptionMatrixWithAllocation: (x) => x.ItemID, + tieredWithProration: (x) => x.ItemID, + newSubscriptionUnitWithProration: (x) => x.ItemID, + newSubscriptionGroupedAllocation: (x) => x.ItemID, + newSubscriptionBulkWithProration: (x) => x.ItemID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ItemID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ItemID, + groupedWithMinMaxThresholds: (x) => x.ItemID, + newSubscriptionMatrixWithDisplayName: (x) => x.ItemID, + newSubscriptionGroupedTieredPackage: (x) => x.ItemID, + newSubscriptionMaxGroupTieredPackage: (x) => x.ItemID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ItemID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ItemID, + newSubscriptionCumulativeGroupedBulk: (x) => x.ItemID, + cumulativeGroupedAllocation: (x) => x.ItemID, + newSubscriptionMinimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID ); } } - public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) + public string Name { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.Name, + newSubscriptionTiered: (x) => x.Name, + newSubscriptionBulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + newSubscriptionPackage: (x) => x.Name, + newSubscriptionMatrix: (x) => x.Name, + newSubscriptionThresholdTotalAmount: (x) => x.Name, + newSubscriptionTieredPackage: (x) => x.Name, + newSubscriptionTieredWithMinimum: (x) => x.Name, + newSubscriptionGroupedTiered: (x) => x.Name, + newSubscriptionTieredPackageWithMinimum: (x) => x.Name, + newSubscriptionPackageWithAllocation: (x) => x.Name, + newSubscriptionUnitWithPercent: (x) => x.Name, + newSubscriptionMatrixWithAllocation: (x) => x.Name, + tieredWithProration: (x) => x.Name, + newSubscriptionUnitWithProration: (x) => x.Name, + newSubscriptionGroupedAllocation: (x) => x.Name, + newSubscriptionBulkWithProration: (x) => x.Name, + newSubscriptionGroupedWithProratedMinimum: (x) => x.Name, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.Name, + groupedWithMinMaxThresholds: (x) => x.Name, + newSubscriptionMatrixWithDisplayName: (x) => x.Name, + newSubscriptionGroupedTieredPackage: (x) => x.Name, + newSubscriptionMaxGroupTieredPackage: (x) => x.Name, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Name, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Name, + newSubscriptionCumulativeGroupedBulk: (x) => x.Name, + cumulativeGroupedAllocation: (x) => x.Name, + newSubscriptionMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name + ); + } } - public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) + public string? BillableMetricID { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.BillableMetricID, + newSubscriptionTiered: (x) => x.BillableMetricID, + newSubscriptionBulk: (x) => x.BillableMetricID, + bulkWithFilters: (x) => x.BillableMetricID, + newSubscriptionPackage: (x) => x.BillableMetricID, + newSubscriptionMatrix: (x) => x.BillableMetricID, + newSubscriptionThresholdTotalAmount: (x) => x.BillableMetricID, + newSubscriptionTieredPackage: (x) => x.BillableMetricID, + newSubscriptionTieredWithMinimum: (x) => x.BillableMetricID, + newSubscriptionGroupedTiered: (x) => x.BillableMetricID, + newSubscriptionTieredPackageWithMinimum: (x) => x.BillableMetricID, + newSubscriptionPackageWithAllocation: (x) => x.BillableMetricID, + newSubscriptionUnitWithPercent: (x) => x.BillableMetricID, + newSubscriptionMatrixWithAllocation: (x) => x.BillableMetricID, + tieredWithProration: (x) => x.BillableMetricID, + newSubscriptionUnitWithProration: (x) => x.BillableMetricID, + newSubscriptionGroupedAllocation: (x) => x.BillableMetricID, + newSubscriptionBulkWithProration: (x) => x.BillableMetricID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BillableMetricID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillableMetricID, + groupedWithMinMaxThresholds: (x) => x.BillableMetricID, + newSubscriptionMatrixWithDisplayName: (x) => x.BillableMetricID, + newSubscriptionGroupedTieredPackage: (x) => x.BillableMetricID, + newSubscriptionMaxGroupTieredPackage: (x) => x.BillableMetricID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, + newSubscriptionCumulativeGroupedBulk: (x) => x.BillableMetricID, + cumulativeGroupedAllocation: (x) => x.BillableMetricID, + newSubscriptionMinimumComposite: (x) => x.BillableMetricID, + percent: (x) => x.BillableMetricID, + eventOutput: (x) => x.BillableMetricID + ); + } } - public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) + public bool? BilledInAdvance { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.BilledInAdvance, + newSubscriptionTiered: (x) => x.BilledInAdvance, + newSubscriptionBulk: (x) => x.BilledInAdvance, + bulkWithFilters: (x) => x.BilledInAdvance, + newSubscriptionPackage: (x) => x.BilledInAdvance, + newSubscriptionMatrix: (x) => x.BilledInAdvance, + newSubscriptionThresholdTotalAmount: (x) => x.BilledInAdvance, + newSubscriptionTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionTieredWithMinimum: (x) => x.BilledInAdvance, + newSubscriptionGroupedTiered: (x) => x.BilledInAdvance, + newSubscriptionTieredPackageWithMinimum: (x) => x.BilledInAdvance, + newSubscriptionPackageWithAllocation: (x) => x.BilledInAdvance, + newSubscriptionUnitWithPercent: (x) => x.BilledInAdvance, + newSubscriptionMatrixWithAllocation: (x) => x.BilledInAdvance, + tieredWithProration: (x) => x.BilledInAdvance, + newSubscriptionUnitWithProration: (x) => x.BilledInAdvance, + newSubscriptionGroupedAllocation: (x) => x.BilledInAdvance, + newSubscriptionBulkWithProration: (x) => x.BilledInAdvance, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BilledInAdvance, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, + groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, + newSubscriptionMatrixWithDisplayName: (x) => x.BilledInAdvance, + newSubscriptionGroupedTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionMaxGroupTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, + newSubscriptionCumulativeGroupedBulk: (x) => x.BilledInAdvance, + cumulativeGroupedAllocation: (x) => x.BilledInAdvance, + newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); + } } - public ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.BillingCycleConfiguration, + newSubscriptionTiered: (x) => x.BillingCycleConfiguration, + newSubscriptionBulk: (x) => x.BillingCycleConfiguration, + bulkWithFilters: (x) => x.BillingCycleConfiguration, + newSubscriptionPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrix: (x) => x.BillingCycleConfiguration, + newSubscriptionThresholdTotalAmount: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredWithMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedTiered: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionPackageWithAllocation: (x) => x.BillingCycleConfiguration, + newSubscriptionUnitWithPercent: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrixWithAllocation: (x) => x.BillingCycleConfiguration, + tieredWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionUnitWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedAllocation: (x) => x.BillingCycleConfiguration, + newSubscriptionBulkWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, + newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, + newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, + percent: (x) => x.BillingCycleConfiguration, + eventOutput: (x) => x.BillingCycleConfiguration + ); + } } - public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) + public double? ConversionRate { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.ConversionRate, + newSubscriptionTiered: (x) => x.ConversionRate, + newSubscriptionBulk: (x) => x.ConversionRate, + bulkWithFilters: (x) => x.ConversionRate, + newSubscriptionPackage: (x) => x.ConversionRate, + newSubscriptionMatrix: (x) => x.ConversionRate, + newSubscriptionThresholdTotalAmount: (x) => x.ConversionRate, + newSubscriptionTieredPackage: (x) => x.ConversionRate, + newSubscriptionTieredWithMinimum: (x) => x.ConversionRate, + newSubscriptionGroupedTiered: (x) => x.ConversionRate, + newSubscriptionTieredPackageWithMinimum: (x) => x.ConversionRate, + newSubscriptionPackageWithAllocation: (x) => x.ConversionRate, + newSubscriptionUnitWithPercent: (x) => x.ConversionRate, + newSubscriptionMatrixWithAllocation: (x) => x.ConversionRate, + tieredWithProration: (x) => x.ConversionRate, + newSubscriptionUnitWithProration: (x) => x.ConversionRate, + newSubscriptionGroupedAllocation: (x) => x.ConversionRate, + newSubscriptionBulkWithProration: (x) => x.ConversionRate, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ConversionRate, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ConversionRate, + groupedWithMinMaxThresholds: (x) => x.ConversionRate, + newSubscriptionMatrixWithDisplayName: (x) => x.ConversionRate, + newSubscriptionGroupedTieredPackage: (x) => x.ConversionRate, + newSubscriptionMaxGroupTieredPackage: (x) => x.ConversionRate, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ConversionRate, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ConversionRate, + newSubscriptionCumulativeGroupedBulk: (x) => x.ConversionRate, + cumulativeGroupedAllocation: (x) => x.ConversionRate, + newSubscriptionMinimumComposite: (x) => x.ConversionRate, + percent: (x) => x.ConversionRate, + eventOutput: (x) => x.ConversionRate + ); + } } - public ReplaceAdjustmentAdjustment(JsonElement element) + public string? Currency { - this._element = element; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPercentageDiscount(out var value)) { - /// // `value` is of type `NewPercentageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) - { - value = this.Value as NewPercentageDiscount; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) - { - value = this.Value as NewUsageDiscount; - return value != null; + get + { + return Match( + 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; + 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 + ); + } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the 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? InvoiceGroupingKey { - switch (this.Value) + get { - case NewPercentageDiscount value: - newPercentageDiscount(value); - break; - case NewUsageDiscount value: - newUsageDiscount(value); - break; - case NewAmountDiscount value: - newAmountDiscount(value); - break; - case NewMinimum value: - newMinimum(value); - break; - case NewMaximum value: - newMaximum(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" - ); + return Match( + newSubscriptionUnit: (x) => x.InvoiceGroupingKey, + newSubscriptionTiered: (x) => x.InvoiceGroupingKey, + newSubscriptionBulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + newSubscriptionPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrix: (x) => x.InvoiceGroupingKey, + newSubscriptionThresholdTotalAmount: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredWithMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedTiered: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionPackageWithAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionUnitWithPercent: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + tieredWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionUnitWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionBulkWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, + newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, + cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func newPercentageDiscount, - System::Func newUsageDiscount, - System::Func newAmountDiscount, - System::Func newMinimum, - System::Func newMaximum - ) + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - return this.Value switch + get { - NewPercentageDiscount value => newPercentageDiscount(value), - NewUsageDiscount value => newUsageDiscount(value), - NewAmountDiscount value => newAmountDiscount(value), - NewMinimum value => newMinimum(value), - NewMaximum value => newMaximum(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" - ), - }; + return Match( + newSubscriptionUnit: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTiered: (x) => x.InvoicingCycleConfiguration, + newSubscriptionBulk: (x) => x.InvoicingCycleConfiguration, + bulkWithFilters: (x) => x.InvoicingCycleConfiguration, + newSubscriptionPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrix: (x) => x.InvoicingCycleConfiguration, + newSubscriptionThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedTiered: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, + newSubscriptionUnitWithPercent: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + tieredWithProration: (x) => x.InvoicingCycleConfiguration, + newSubscriptionUnitWithProration: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + newSubscriptionBulkWithProration: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, + newSubscriptionScalableMatrixWithTieredPricing: (x) => + x.InvoicingCycleConfiguration, + newSubscriptionCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMinimumComposite: (x) => x.InvoicingCycleConfiguration, + percent: (x) => x.InvoicingCycleConfiguration, + eventOutput: (x) => x.InvoicingCycleConfiguration + ); + } } - public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount value) => - new(value); - - public static implicit operator ReplaceAdjustmentAdjustment(NewUsageDiscount value) => - new(value); - - public static implicit operator ReplaceAdjustmentAdjustment(NewAmountDiscount value) => - new(value); - - public static implicit operator ReplaceAdjustmentAdjustment(NewMinimum value) => new(value); - - public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum value) => new(value); + 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 + ); + } + } - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() + public string? ReferenceID { - if (this.Value == null) + get { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplaceAdjustmentAdjustment" + return Match( + newSubscriptionUnit: (x) => x.ReferenceID, + newSubscriptionTiered: (x) => x.ReferenceID, + newSubscriptionBulk: (x) => x.ReferenceID, + bulkWithFilters: (x) => x.ReferenceID, + newSubscriptionPackage: (x) => x.ReferenceID, + newSubscriptionMatrix: (x) => x.ReferenceID, + newSubscriptionThresholdTotalAmount: (x) => x.ReferenceID, + newSubscriptionTieredPackage: (x) => x.ReferenceID, + newSubscriptionTieredWithMinimum: (x) => x.ReferenceID, + newSubscriptionGroupedTiered: (x) => x.ReferenceID, + newSubscriptionTieredPackageWithMinimum: (x) => x.ReferenceID, + newSubscriptionPackageWithAllocation: (x) => x.ReferenceID, + newSubscriptionUnitWithPercent: (x) => x.ReferenceID, + newSubscriptionMatrixWithAllocation: (x) => x.ReferenceID, + tieredWithProration: (x) => x.ReferenceID, + newSubscriptionUnitWithProration: (x) => x.ReferenceID, + newSubscriptionGroupedAllocation: (x) => x.ReferenceID, + newSubscriptionBulkWithProration: (x) => x.ReferenceID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ReferenceID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ReferenceID, + groupedWithMinMaxThresholds: (x) => x.ReferenceID, + newSubscriptionMatrixWithDisplayName: (x) => x.ReferenceID, + newSubscriptionGroupedTieredPackage: (x) => x.ReferenceID, + newSubscriptionMaxGroupTieredPackage: (x) => x.ReferenceID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ReferenceID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, + newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, + cumulativeGroupedAllocation: (x) => x.ReferenceID, + newSubscriptionMinimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID ); } - this.Switch( - (newPercentageDiscount) => newPercentageDiscount.Validate(), - (newUsageDiscount) => newUsageDiscount.Validate(), - (newAmountDiscount) => newAmountDiscount.Validate(), - (newMinimum) => newMinimum.Validate(), - (newMaximum) => newMaximum.Validate() - ); } - public virtual bool Equals(ReplaceAdjustmentAdjustment? other) + public ReplacePricePrice(NewSubscriptionUnitPrice value, JsonElement? element = null) { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + this.Value = value; + this._element = element; } - public override int GetHashCode() + public ReplacePricePrice(NewSubscriptionTieredPrice value, JsonElement? element = null) { - return 0; + this.Value = value; + this._element = element; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + public ReplacePricePrice(NewSubscriptionBulkPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } -sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter -{ - public override ReplaceAdjustmentAdjustment? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + public ReplacePricePrice(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) { - var element = JsonSerializer.Deserialize(ref reader, options); - string? adjustmentType; - try - { - adjustmentType = element.GetProperty("adjustment_type").GetString(); - } - catch - { - adjustmentType = null; - } + this.Value = value; + this._element = element; + } - switch (adjustmentType) - { - case "percentage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePrice(NewSubscriptionPackagePrice 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 - } - - 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 - } + public ReplacePricePrice(NewSubscriptionMatrixPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "maximum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePrice( + NewSubscriptionThresholdTotalAmountPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - default: - { - return new ReplaceAdjustmentAdjustment(element); - } - } + public ReplacePricePrice(NewSubscriptionTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; } - public override void Write( - Utf8JsonWriter writer, - ReplaceAdjustmentAdjustment value, - JsonSerializerOptions options + public ReplacePricePrice( + NewSubscriptionTieredWithMinimumPrice value, + JsonElement? element = null ) { - JsonSerializer.Serialize(writer, value.Json, options); + this.Value = value; + this._element = element; } -} -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class ReplacePrice : JsonModel -{ - /// - /// The id of the price on the plan to replace in the subscription. - /// - public required string ReplacesPriceID + public ReplacePricePrice(NewSubscriptionGroupedTieredPrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_price_id"); - } - init { this._rawData.Set("replaces_price_id", value); } + this.Value = value; + this._element = element; } - /// - /// The definition of a new allocation price to create and add to the subscription. - /// - public NewAllocationPrice? AllocationPrice + public ReplacePricePrice( + NewSubscriptionTieredPackageWithMinimumPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("allocation_price"); - } - init { this._rawData.Set("allocation_price", value); } + this.Value = value; + this._element = element; } - /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for - /// the replacement price. - /// - [System::Obsolete("deprecated")] - public IReadOnlyList? Discounts + public ReplacePricePrice( + NewSubscriptionPackageWithAllocationPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct>("discounts"); - } - init - { - this._rawData.Set?>( - "discounts", - value == null ? null : ImmutableArray.ToImmutableArray(value) - ); - } + this.Value = value; + this._element = element; } - /// - /// The external price id of the price to add to the subscription. - /// - public string? ExternalPriceID + public ReplacePricePrice(NewSubscriptionUnitWithPercentPrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } + this.Value = value; + this._element = element; } - /// - /// The new quantity of the price, if the price is a fixed price. - /// - public double? FixedPriceQuantity + public ReplacePricePrice( + NewSubscriptionMatrixWithAllocationPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } + this.Value = value; + this._element = element; } - /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount - /// for the replacement price. - /// - [System::Obsolete("deprecated")] - public string? MaximumAmount + public ReplacePricePrice( + ReplacePricePriceTieredWithProration value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("maximum_amount"); - } - init { this._rawData.Set("maximum_amount", value); } + this.Value = value; + this._element = element; } - /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount - /// for the replacement price. - /// - [System::Obsolete("deprecated")] - public string? MinimumAmount + public ReplacePricePrice( + NewSubscriptionUnitWithProrationPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("minimum_amount"); - } - init { this._rawData.Set("minimum_amount", value); } + this.Value = value; + this._element = element; } - /// - /// New subscription price request body params. - /// - public ReplacePricePrice? Price + public ReplacePricePrice( + NewSubscriptionGroupedAllocationPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("price"); - } - init { this._rawData.Set("price", value); } + this.Value = value; + this._element = element; } - /// - /// The id of the price to add to the subscription. - /// - public string? PriceID + public ReplacePricePrice( + NewSubscriptionBulkWithProrationPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("price_id"); - } - init { this._rawData.Set("price_id", value); } + this.Value = value; + this._element = element; } - /// - public override void Validate() + public ReplacePricePrice( + NewSubscriptionGroupedWithProratedMinimumPrice value, + JsonElement? element = null + ) { - _ = this.ReplacesPriceID; - this.AllocationPrice?.Validate(); - foreach (var item in this.Discounts ?? []) - { - item.Validate(); - } - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.MaximumAmount; - _ = this.MinimumAmount; - this.Price?.Validate(); - _ = this.PriceID; + this.Value = value; + this._element = element; } - public ReplacePrice() { } - - public ReplacePrice(ReplacePrice replacePrice) - : base(replacePrice) { } + public ReplacePricePrice( + NewSubscriptionGroupedWithMeteredMinimumPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public ReplacePrice(IReadOnlyDictionary rawData) + public ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds value, + JsonElement? element = null + ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePrice(FrozenDictionary rawData) + public ReplacePricePrice( + NewSubscriptionMatrixWithDisplayNamePrice 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( + NewSubscriptionGroupedTieredPackagePrice value, + JsonElement? element = null + ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public ReplacePrice(string replacesPriceID) - : this() + public ReplacePricePrice( + NewSubscriptionMaxGroupTieredPackagePrice 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( + NewSubscriptionScalableMatrixWithUnitPricingPrice 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( + NewSubscriptionScalableMatrixWithTieredPricingPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - JsonElement? _element = null; + public ReplacePricePrice( + NewSubscriptionCumulativeGroupedBulkPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public JsonElement Json + public ReplacePricePrice( + ReplacePricePriceCumulativeGroupedAllocation value, + JsonElement? element = null + ) { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } + this.Value = value; + this._element = element; } - public string ItemID + public ReplacePricePrice( + NewSubscriptionMinimumCompositePrice 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(ReplacePricePricePercent 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(ReplacePricePriceEventOutput 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(JsonElement 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, - minimum: (x) => x.BilledInAdvance, - newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, - percent: (x) => x.BilledInAdvance, - eventOutput: (x) => x.BilledInAdvance - ); - } + this._element = element; } - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.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.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 NewSubscriptionUnitPrice; + 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.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.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 NewSubscriptionTieredPrice; + 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.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.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 NewSubscriptionBulkPrice; + return value != null; } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `ReplacePricePriceBulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters( + [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value + ) { - get - { - return Match( - 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 ReplacePricePriceBulkWithFilters; + 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.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; } - 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.TryPickNewSubscriptionMatrix(out var value)) { + /// // `value` is of type `NewSubscriptionMatrixPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionMatrix( + [NotNullWhen(true)] out NewSubscriptionMatrixPrice? value + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.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 NewSubscriptionMatrixPrice; + 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.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.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 NewSubscriptionThresholdTotalAmountPrice; + 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.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.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 NewSubscriptionTieredPackagePrice; + 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.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.ReferenceID, - newSubscriptionTiered: (x) => x.ReferenceID, - newSubscriptionBulk: (x) => x.ReferenceID, - bulkWithFilters: (x) => x.ReferenceID, - newSubscriptionPackage: (x) => x.ReferenceID, - newSubscriptionMatrix: (x) => x.ReferenceID, - newSubscriptionThresholdTotalAmount: (x) => x.ReferenceID, - newSubscriptionTieredPackage: (x) => x.ReferenceID, - newSubscriptionTieredWithMinimum: (x) => x.ReferenceID, - newSubscriptionGroupedTiered: (x) => x.ReferenceID, - newSubscriptionTieredPackageWithMinimum: (x) => x.ReferenceID, - newSubscriptionPackageWithAllocation: (x) => x.ReferenceID, - newSubscriptionUnitWithPercent: (x) => x.ReferenceID, - newSubscriptionMatrixWithAllocation: (x) => x.ReferenceID, - tieredWithProration: (x) => x.ReferenceID, - newSubscriptionUnitWithProration: (x) => x.ReferenceID, - newSubscriptionGroupedAllocation: (x) => x.ReferenceID, - newSubscriptionBulkWithProration: (x) => x.ReferenceID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ReferenceID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ReferenceID, - groupedWithMinMaxThresholds: (x) => x.ReferenceID, - newSubscriptionMatrixWithDisplayName: (x) => x.ReferenceID, - newSubscriptionGroupedTieredPackage: (x) => x.ReferenceID, - newSubscriptionMaxGroupTieredPackage: (x) => x.ReferenceID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ReferenceID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, - newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, - cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, - newSubscriptionMinimumComposite: (x) => x.ReferenceID, - percent: (x) => x.ReferenceID, - eventOutput: (x) => x.ReferenceID - ); - } - } - - public ReplacePricePrice(NewSubscriptionUnitPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionTieredWithMinimumPrice; + return value != null; } - public ReplacePricePrice(NewSubscriptionTieredPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionGroupedTiered(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionGroupedTiered( + [NotNullWhen(true)] out NewSubscriptionGroupedTieredPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionGroupedTieredPrice; + return value != null; } - public ReplacePricePrice(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.TryPickNewSubscriptionTieredPackageWithMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionTieredPackageWithMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTieredPackageWithMinimum( + [NotNullWhen(true)] out NewSubscriptionTieredPackageWithMinimumPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionTieredPackageWithMinimumPrice; + return value != null; } - public ReplacePricePrice(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewSubscriptionPackageWithAllocation(out var value)) { + /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionPackageWithAllocation( + [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionPackageWithAllocationPrice; + return value != null; } - public ReplacePricePrice(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.TryPickNewSubscriptionUnitWithPercent(out var value)) { + /// // `value` is of type `NewSubscriptionUnitWithPercentPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionUnitWithPercent( + [NotNullWhen(true)] out NewSubscriptionUnitWithPercentPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionUnitWithPercentPrice; + return value != null; } - public ReplacePricePrice(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.TryPickNewSubscriptionMatrixWithAllocation(out var value)) { + /// // `value` is of type `NewSubscriptionMatrixWithAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionMatrixWithAllocation( + [NotNullWhen(true)] out NewSubscriptionMatrixWithAllocationPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionMatrixWithAllocationPrice; + return value != null; } - public ReplacePricePrice( - 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.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `ReplacePricePriceTieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTieredWithProration( + [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value ) { - this.Value = value; - this._element = element; + value = this.Value as ReplacePricePriceTieredWithProration; + return value != null; } - public ReplacePricePrice(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.TryPickNewSubscriptionUnitWithProration(out var value)) { + /// // `value` is of type `NewSubscriptionUnitWithProrationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionUnitWithProration( + [NotNullWhen(true)] out NewSubscriptionUnitWithProrationPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionUnitWithProrationPrice; + return value != null; } - public ReplacePricePrice( - 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.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 ReplacePricePrice(NewSubscriptionGroupedTieredPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.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 ReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice value, - JsonElement? element = null + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.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 ReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(NewSubscriptionUnitWithPercentPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionMatrixWithAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - ReplacePricePriceTieredWithProration value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionMaxGroupTieredPackagePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(ReplacePricePriceMinimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice( - NewSubscriptionMinimumCompositePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } - - public ReplacePricePrice(JsonElement element) - { - this._element = element; + value = this.Value as 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. + /// 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. + /// 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 `ReplacePricePriceGroupedWithMinMaxThresholds` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTiered( - [NotNullWhen(true)] out NewSubscriptionTieredPrice? value + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value ) { - value = this.Value as NewSubscriptionTieredPrice; + value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// - /// Consider using or if you need to handle every variant. + /// 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. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `ReplacePricePriceBulkWithFilters` + /// if (instance.TryPickNewSubscriptionGroupedTieredPackage(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedTieredPackagePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value + public bool TryPickNewSubscriptionGroupedTieredPackage( + [NotNullWhen(true)] out NewSubscriptionGroupedTieredPackagePrice? value ) { - value = this.Value as ReplacePricePriceBulkWithFilters; + value = this.Value as NewSubscriptionGroupedTieredPackagePrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionPackage(out var value)) { - /// // `value` is of type `NewSubscriptionPackagePrice` + /// if (instance.TryPickNewSubscriptionMaxGroupTieredPackage(out var value)) { + /// // `value` is of type `NewSubscriptionMaxGroupTieredPackagePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionPackage( - [NotNullWhen(true)] out NewSubscriptionPackagePrice? value + public bool TryPickNewSubscriptionMaxGroupTieredPackage( + [NotNullWhen(true)] out NewSubscriptionMaxGroupTieredPackagePrice? value ) { - value = this.Value as NewSubscriptionPackagePrice; + 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. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionMatrix(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixPrice` + /// if (instance.TryPickNewSubscriptionScalableMatrixWithUnitPricing(out var value)) { + /// // `value` is of type `NewSubscriptionScalableMatrixWithUnitPricingPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionMatrix( - [NotNullWhen(true)] out NewSubscriptionMatrixPrice? value + public bool TryPickNewSubscriptionScalableMatrixWithUnitPricing( + [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithUnitPricingPrice? value ) { - value = this.Value as NewSubscriptionMatrixPrice; + 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. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewSubscriptionThresholdTotalAmountPrice` + /// if (instance.TryPickNewSubscriptionScalableMatrixWithTieredPricing(out var value)) { + /// // `value` is of type `NewSubscriptionScalableMatrixWithTieredPricingPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionThresholdTotalAmount( - [NotNullWhen(true)] out NewSubscriptionThresholdTotalAmountPrice? value + public bool TryPickNewSubscriptionScalableMatrixWithTieredPricing( + [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithTieredPricingPrice? value ) { - value = this.Value as NewSubscriptionThresholdTotalAmountPrice; + 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. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackagePrice` + /// if (instance.TryPickNewSubscriptionCumulativeGroupedBulk(out var value)) { + /// // `value` is of type `NewSubscriptionCumulativeGroupedBulkPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTieredPackage( - [NotNullWhen(true)] out NewSubscriptionTieredPackagePrice? value + public bool TryPickNewSubscriptionCumulativeGroupedBulk( + [NotNullWhen(true)] out NewSubscriptionCumulativeGroupedBulkPrice? value ) { - value = this.Value as NewSubscriptionTieredPackagePrice; + 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. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionTieredWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` + /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { + /// // `value` is of type `ReplacePricePriceCumulativeGroupedAllocation` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTieredWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] out ReplacePricePriceCumulativeGroupedAllocation? value ) { - value = this.Value as NewSubscriptionTieredWithMinimumPrice; + value = this.Value as ReplacePricePriceCumulativeGroupedAllocation; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionGroupedTiered(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedTieredPrice` + /// if (instance.TryPickNewSubscriptionMinimumComposite(out var value)) { + /// // `value` is of type `NewSubscriptionMinimumCompositePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionGroupedTiered( - [NotNullWhen(true)] out NewSubscriptionGroupedTieredPrice? value + public bool TryPickNewSubscriptionMinimumComposite( + [NotNullWhen(true)] out NewSubscriptionMinimumCompositePrice? value ) { - value = this.Value as NewSubscriptionGroupedTieredPrice; + 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. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackageWithMinimumPrice` + /// if (instance.TryPickPercent(out var value)) { + /// // `value` is of type `ReplacePricePricePercent` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTieredPackageWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredPackageWithMinimumPrice? value - ) + public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) { - value = this.Value as NewSubscriptionTieredPackageWithMinimumPrice; + value = this.Value as ReplacePricePricePercent; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionPackageWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` + /// if (instance.TryPickEventOutput(out var value)) { + /// // `value` is of type `ReplacePricePriceEventOutput` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionPackageWithAllocation( - [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value - ) + public bool TryPickEventOutput([NotNullWhen(true)] out ReplacePricePriceEventOutput? value) { - value = this.Value as NewSubscriptionPackageWithAllocationPrice; + value = this.Value as ReplacePricePriceEventOutput; return value != null; } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. + /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// - /// - /// if (instance.TryPickNewSubscriptionUnitWithPercent(out var value)) { - /// // `value` is of type `NewSubscriptionUnitWithPercentPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionUnitWithPercent( - [NotNullWhen(true)] out NewSubscriptionUnitWithPercentPrice? value - ) - { - value = this.Value as NewSubscriptionUnitWithPercentPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. /// - /// Consider using or if you need to handle every variant. + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// /// /// /// - /// if (instance.TryPickNewSubscriptionMatrixWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithAllocationPrice` - /// Console.WriteLine(value); - /// } + /// instance.Switch( + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (ReplacePricePriceBulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (ReplacePricePriceTieredWithProration value) => {...}, + /// (NewSubscriptionUnitWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedAllocationPrice value) => {...}, + /// (NewSubscriptionBulkWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, + /// (ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, + /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, + /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, + /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (ReplacePricePricePercent value) => {...}, + /// (ReplacePricePriceEventOutput value) => {...} + /// ); /// /// /// - public bool TryPickNewSubscriptionMatrixWithAllocation( - [NotNullWhen(true)] out NewSubscriptionMatrixWithAllocationPrice? 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 NewSubscriptionMatrixWithAllocationPrice; - return value != null; + switch (this.Value) + { + case NewSubscriptionUnitPrice value: + newSubscriptionUnit(value); + break; + case NewSubscriptionTieredPrice value: + newSubscriptionTiered(value); + break; + case NewSubscriptionBulkPrice value: + newSubscriptionBulk(value); + break; + case ReplacePricePriceBulkWithFilters value: + bulkWithFilters(value); + break; + case NewSubscriptionPackagePrice value: + newSubscriptionPackage(value); + break; + case NewSubscriptionMatrixPrice value: + newSubscriptionMatrix(value); + break; + case NewSubscriptionThresholdTotalAmountPrice value: + newSubscriptionThresholdTotalAmount(value); + break; + case NewSubscriptionTieredPackagePrice value: + newSubscriptionTieredPackage(value); + break; + case NewSubscriptionTieredWithMinimumPrice value: + newSubscriptionTieredWithMinimum(value); + break; + case NewSubscriptionGroupedTieredPrice value: + newSubscriptionGroupedTiered(value); + break; + case NewSubscriptionTieredPackageWithMinimumPrice value: + newSubscriptionTieredPackageWithMinimum(value); + break; + case NewSubscriptionPackageWithAllocationPrice value: + newSubscriptionPackageWithAllocation(value); + break; + case NewSubscriptionUnitWithPercentPrice value: + newSubscriptionUnitWithPercent(value); + break; + case NewSubscriptionMatrixWithAllocationPrice value: + newSubscriptionMatrixWithAllocation(value); + break; + case ReplacePricePriceTieredWithProration value: + tieredWithProration(value); + break; + case NewSubscriptionUnitWithProrationPrice value: + newSubscriptionUnitWithProration(value); + break; + case NewSubscriptionGroupedAllocationPrice value: + newSubscriptionGroupedAllocation(value); + break; + case NewSubscriptionBulkWithProrationPrice value: + newSubscriptionBulkWithProration(value); + break; + case NewSubscriptionGroupedWithProratedMinimumPrice value: + newSubscriptionGroupedWithProratedMinimum(value); + break; + case NewSubscriptionGroupedWithMeteredMinimumPrice value: + newSubscriptionGroupedWithMeteredMinimum(value); + break; + case ReplacePricePriceGroupedWithMinMaxThresholds value: + groupedWithMinMaxThresholds(value); + break; + case NewSubscriptionMatrixWithDisplayNamePrice value: + newSubscriptionMatrixWithDisplayName(value); + break; + case NewSubscriptionGroupedTieredPackagePrice value: + newSubscriptionGroupedTieredPackage(value); + break; + case NewSubscriptionMaxGroupTieredPackagePrice value: + newSubscriptionMaxGroupTieredPackage(value); + break; + case NewSubscriptionScalableMatrixWithUnitPricingPrice value: + newSubscriptionScalableMatrixWithUnitPricing(value); + break; + case NewSubscriptionScalableMatrixWithTieredPricingPrice value: + newSubscriptionScalableMatrixWithTieredPricing(value); + break; + case NewSubscriptionCumulativeGroupedBulkPrice value: + newSubscriptionCumulativeGroupedBulk(value); + break; + case ReplacePricePriceCumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case NewSubscriptionMinimumCompositePrice value: + newSubscriptionMinimumComposite(value); + break; + case ReplacePricePricePercent value: + percent(value); + break; + case ReplacePricePriceEventOutput value: + eventOutput(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePrice" + ); + } } /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. /// - /// Consider using or if you need to handle every variant. + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// /// /// /// - /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `ReplacePricePriceTieredWithProration` - /// Console.WriteLine(value); - /// } + /// var result = instance.Match( + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (ReplacePricePriceBulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (ReplacePricePriceTieredWithProration value) => {...}, + /// (NewSubscriptionUnitWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedAllocationPrice value) => {...}, + /// (NewSubscriptionBulkWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, + /// (ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, + /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, + /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, + /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (ReplacePricePricePercent value) => {...}, + /// (ReplacePricePriceEventOutput value) => {...} + /// ); /// /// /// - public bool 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.TryPickNewSubscriptionUnitWithProration(out var value)) { - /// // `value` is of type `NewSubscriptionUnitWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionUnitWithProration( - [NotNullWhen(true)] out NewSubscriptionUnitWithProrationPrice? value - ) - { - value = this.Value as NewSubscriptionUnitWithProrationPrice; - return value != null; - } - - /// - /// Returns true and sets the 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; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionBulkWithProration(out var value)) { - /// // `value` is of type `NewSubscriptionBulkWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionBulkWithProration( - [NotNullWhen(true)] out NewSubscriptionBulkWithProrationPrice? value - ) - { - value = this.Value as NewSubscriptionBulkWithProrationPrice; - return value != null; - } - - /// - /// Returns true and sets the 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; - } - - /// - /// Returns true and sets the 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; - } - - /// - /// Returns true and sets the 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.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; - } - - /// - /// Returns true and sets the 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; - } - - /// - /// Returns true and sets the 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; - } - - /// - /// Returns true and sets the 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; - } - - /// - /// Returns true and sets the 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; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewSubscriptionCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionCumulativeGroupedBulk( - [NotNullWhen(true)] out NewSubscriptionCumulativeGroupedBulkPrice? value - ) - { - value = this.Value as NewSubscriptionCumulativeGroupedBulkPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `ReplacePricePriceCumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out ReplacePricePriceCumulativeGroupedAllocation? value - ) - { - value = this.Value as ReplacePricePriceCumulativeGroupedAllocation; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `ReplacePricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out ReplacePricePriceMinimum? value) - { - value = this.Value as ReplacePricePriceMinimum; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMinimumComposite(out var value)) { - /// // `value` is of type `NewSubscriptionMinimumCompositePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMinimumComposite( - [NotNullWhen(true)] out NewSubscriptionMinimumCompositePrice? value - ) - { - value = this.Value as NewSubscriptionMinimumCompositePrice; - return value != null; - } - - /// - /// Returns true and sets the 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( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (ReplacePricePriceBulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (ReplacePricePriceTieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, - /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, - /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (ReplacePricePriceMinimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (ReplacePricePricePercent value) => {...}, - /// (ReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action newSubscriptionUnit, - System::Action newSubscriptionTiered, - System::Action newSubscriptionBulk, - System::Action bulkWithFilters, - System::Action newSubscriptionPackage, - System::Action newSubscriptionMatrix, - System::Action newSubscriptionThresholdTotalAmount, - System::Action newSubscriptionTieredPackage, - System::Action newSubscriptionTieredWithMinimum, - System::Action newSubscriptionGroupedTiered, - System::Action newSubscriptionTieredPackageWithMinimum, - System::Action newSubscriptionPackageWithAllocation, - System::Action newSubscriptionUnitWithPercent, - System::Action newSubscriptionMatrixWithAllocation, - System::Action tieredWithProration, - System::Action newSubscriptionUnitWithProration, - System::Action newSubscriptionGroupedAllocation, - System::Action newSubscriptionBulkWithProration, - System::Action newSubscriptionGroupedWithProratedMinimum, - System::Action newSubscriptionGroupedWithMeteredMinimum, - System::Action groupedWithMinMaxThresholds, - System::Action newSubscriptionMatrixWithDisplayName, - System::Action newSubscriptionGroupedTieredPackage, - System::Action newSubscriptionMaxGroupTieredPackage, - System::Action newSubscriptionScalableMatrixWithUnitPricing, - System::Action newSubscriptionScalableMatrixWithTieredPricing, - System::Action newSubscriptionCumulativeGroupedBulk, - System::Action cumulativeGroupedAllocation, - System::Action minimum, - System::Action newSubscriptionMinimumComposite, - System::Action percent, - System::Action eventOutput - ) - { - switch (this.Value) - { - case NewSubscriptionUnitPrice value: - newSubscriptionUnit(value); - break; - case NewSubscriptionTieredPrice value: - newSubscriptionTiered(value); - break; - case NewSubscriptionBulkPrice value: - newSubscriptionBulk(value); - break; - case ReplacePricePriceBulkWithFilters value: - bulkWithFilters(value); - break; - case NewSubscriptionPackagePrice value: - newSubscriptionPackage(value); - break; - case NewSubscriptionMatrixPrice value: - newSubscriptionMatrix(value); - break; - case NewSubscriptionThresholdTotalAmountPrice value: - newSubscriptionThresholdTotalAmount(value); - break; - case NewSubscriptionTieredPackagePrice value: - newSubscriptionTieredPackage(value); - break; - case NewSubscriptionTieredWithMinimumPrice value: - newSubscriptionTieredWithMinimum(value); - break; - case NewSubscriptionGroupedTieredPrice value: - newSubscriptionGroupedTiered(value); - break; - case NewSubscriptionTieredPackageWithMinimumPrice value: - newSubscriptionTieredPackageWithMinimum(value); - break; - case NewSubscriptionPackageWithAllocationPrice value: - newSubscriptionPackageWithAllocation(value); - break; - case NewSubscriptionUnitWithPercentPrice value: - newSubscriptionUnitWithPercent(value); - break; - case NewSubscriptionMatrixWithAllocationPrice value: - newSubscriptionMatrixWithAllocation(value); - break; - case ReplacePricePriceTieredWithProration value: - tieredWithProration(value); - break; - case NewSubscriptionUnitWithProrationPrice value: - newSubscriptionUnitWithProration(value); - break; - case NewSubscriptionGroupedAllocationPrice value: - newSubscriptionGroupedAllocation(value); - break; - case NewSubscriptionBulkWithProrationPrice value: - newSubscriptionBulkWithProration(value); - break; - case NewSubscriptionGroupedWithProratedMinimumPrice value: - newSubscriptionGroupedWithProratedMinimum(value); - break; - case NewSubscriptionGroupedWithMeteredMinimumPrice value: - newSubscriptionGroupedWithMeteredMinimum(value); - break; - case ReplacePricePriceGroupedWithMinMaxThresholds value: - groupedWithMinMaxThresholds(value); - break; - case NewSubscriptionMatrixWithDisplayNamePrice value: - newSubscriptionMatrixWithDisplayName(value); - break; - case NewSubscriptionGroupedTieredPackagePrice value: - newSubscriptionGroupedTieredPackage(value); - break; - case NewSubscriptionMaxGroupTieredPackagePrice value: - newSubscriptionMaxGroupTieredPackage(value); - break; - case NewSubscriptionScalableMatrixWithUnitPricingPrice value: - newSubscriptionScalableMatrixWithUnitPricing(value); - break; - case NewSubscriptionScalableMatrixWithTieredPricingPrice value: - newSubscriptionScalableMatrixWithTieredPricing(value); - break; - case NewSubscriptionCumulativeGroupedBulkPrice value: - newSubscriptionCumulativeGroupedBulk(value); - break; - case ReplacePricePriceCumulativeGroupedAllocation value: - cumulativeGroupedAllocation(value); - break; - case ReplacePricePriceMinimum value: - minimum(value); - break; - case NewSubscriptionMinimumCompositePrice value: - newSubscriptionMinimumComposite(value); - break; - case ReplacePricePricePercent value: - percent(value); - break; - case ReplacePricePriceEventOutput value: - eventOutput(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (ReplacePricePriceBulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (ReplacePricePriceTieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, - /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, - /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (ReplacePricePriceMinimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (ReplacePricePricePercent value) => {...}, - /// (ReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func newSubscriptionUnit, - System::Func newSubscriptionTiered, - System::Func newSubscriptionBulk, - System::Func bulkWithFilters, - System::Func newSubscriptionPackage, - System::Func newSubscriptionMatrix, - System::Func< - NewSubscriptionThresholdTotalAmountPrice, - T - > newSubscriptionThresholdTotalAmount, - System::Func newSubscriptionTieredPackage, - System::Func newSubscriptionTieredWithMinimum, - System::Func newSubscriptionGroupedTiered, - System::Func< - NewSubscriptionTieredPackageWithMinimumPrice, - T - > newSubscriptionTieredPackageWithMinimum, - System::Func< - NewSubscriptionPackageWithAllocationPrice, - T - > newSubscriptionPackageWithAllocation, - System::Func newSubscriptionUnitWithPercent, - System::Func< - NewSubscriptionMatrixWithAllocationPrice, - T - > newSubscriptionMatrixWithAllocation, - System::Func tieredWithProration, - System::Func newSubscriptionUnitWithProration, - System::Func newSubscriptionGroupedAllocation, - System::Func newSubscriptionBulkWithProration, - System::Func< - NewSubscriptionGroupedWithProratedMinimumPrice, - T - > newSubscriptionGroupedWithProratedMinimum, - System::Func< - NewSubscriptionGroupedWithMeteredMinimumPrice, - T - > newSubscriptionGroupedWithMeteredMinimum, - System::Func groupedWithMinMaxThresholds, - System::Func< - NewSubscriptionMatrixWithDisplayNamePrice, - T - > newSubscriptionMatrixWithDisplayName, - System::Func< - NewSubscriptionGroupedTieredPackagePrice, - T - > newSubscriptionGroupedTieredPackage, - System::Func< - NewSubscriptionMaxGroupTieredPackagePrice, - T - > newSubscriptionMaxGroupTieredPackage, - System::Func< - NewSubscriptionScalableMatrixWithUnitPricingPrice, - T - > newSubscriptionScalableMatrixWithUnitPricing, - System::Func< - NewSubscriptionScalableMatrixWithTieredPricingPrice, - T - > newSubscriptionScalableMatrixWithTieredPricing, - System::Func< - NewSubscriptionCumulativeGroupedBulkPrice, - T - > newSubscriptionCumulativeGroupedBulk, - System::Func cumulativeGroupedAllocation, - System::Func minimum, - System::Func newSubscriptionMinimumComposite, - System::Func percent, - System::Func eventOutput - ) - { - return this.Value switch - { - NewSubscriptionUnitPrice value => newSubscriptionUnit(value), - NewSubscriptionTieredPrice value => newSubscriptionTiered(value), - NewSubscriptionBulkPrice value => newSubscriptionBulk(value), - ReplacePricePriceBulkWithFilters value => bulkWithFilters(value), - NewSubscriptionPackagePrice value => newSubscriptionPackage(value), - NewSubscriptionMatrixPrice value => newSubscriptionMatrix(value), - NewSubscriptionThresholdTotalAmountPrice value => newSubscriptionThresholdTotalAmount( - value - ), - NewSubscriptionTieredPackagePrice value => newSubscriptionTieredPackage(value), - NewSubscriptionTieredWithMinimumPrice value => newSubscriptionTieredWithMinimum(value), - NewSubscriptionGroupedTieredPrice value => newSubscriptionGroupedTiered(value), - NewSubscriptionTieredPackageWithMinimumPrice value => - newSubscriptionTieredPackageWithMinimum(value), - NewSubscriptionPackageWithAllocationPrice value => newSubscriptionPackageWithAllocation( - value - ), - NewSubscriptionUnitWithPercentPrice value => newSubscriptionUnitWithPercent(value), - NewSubscriptionMatrixWithAllocationPrice value => newSubscriptionMatrixWithAllocation( - value - ), - ReplacePricePriceTieredWithProration value => tieredWithProration(value), - NewSubscriptionUnitWithProrationPrice value => newSubscriptionUnitWithProration(value), - NewSubscriptionGroupedAllocationPrice value => newSubscriptionGroupedAllocation(value), - NewSubscriptionBulkWithProrationPrice value => newSubscriptionBulkWithProration(value), - NewSubscriptionGroupedWithProratedMinimumPrice value => - newSubscriptionGroupedWithProratedMinimum(value), - NewSubscriptionGroupedWithMeteredMinimumPrice value => - newSubscriptionGroupedWithMeteredMinimum(value), - ReplacePricePriceGroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds( - value - ), - NewSubscriptionMatrixWithDisplayNamePrice value => newSubscriptionMatrixWithDisplayName( - value - ), - NewSubscriptionGroupedTieredPackagePrice value => newSubscriptionGroupedTieredPackage( - value - ), - NewSubscriptionMaxGroupTieredPackagePrice value => newSubscriptionMaxGroupTieredPackage( - value - ), - NewSubscriptionScalableMatrixWithUnitPricingPrice value => - newSubscriptionScalableMatrixWithUnitPricing(value), - NewSubscriptionScalableMatrixWithTieredPricingPrice value => - newSubscriptionScalableMatrixWithTieredPricing(value), - NewSubscriptionCumulativeGroupedBulkPrice value => newSubscriptionCumulativeGroupedBulk( - value - ), - ReplacePricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation( - value - ), - ReplacePricePriceMinimum value => minimum(value), - NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), - ReplacePricePricePercent value => percent(value), - ReplacePricePriceEventOutput value => eventOutput(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ), - }; - } - - public static implicit operator ReplacePricePrice(NewSubscriptionUnitPrice value) => new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionTieredPrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionBulkPrice value) => new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePriceBulkWithFilters value) => - new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionPackagePrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionMatrixPrice value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionThresholdTotalAmountPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionTieredPackagePrice value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionTieredWithMinimumPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionGroupedTieredPrice value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionUnitWithPercentPrice value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionMatrixWithAllocationPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePriceTieredWithProration value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionMaxGroupTieredPackagePrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionScalableMatrixWithUnitPricingPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionScalableMatrixWithTieredPricingPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePriceMinimum value) => new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionMinimumCompositePrice value) => - new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePricePercent value) => new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePriceEventOutput value) => - new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); - } - this.Switch( - (newSubscriptionUnit) => newSubscriptionUnit.Validate(), - (newSubscriptionTiered) => newSubscriptionTiered.Validate(), - (newSubscriptionBulk) => newSubscriptionBulk.Validate(), - (bulkWithFilters) => bulkWithFilters.Validate(), - (newSubscriptionPackage) => newSubscriptionPackage.Validate(), - (newSubscriptionMatrix) => newSubscriptionMatrix.Validate(), - (newSubscriptionThresholdTotalAmount) => newSubscriptionThresholdTotalAmount.Validate(), - (newSubscriptionTieredPackage) => newSubscriptionTieredPackage.Validate(), - (newSubscriptionTieredWithMinimum) => newSubscriptionTieredWithMinimum.Validate(), - (newSubscriptionGroupedTiered) => newSubscriptionGroupedTiered.Validate(), - (newSubscriptionTieredPackageWithMinimum) => - newSubscriptionTieredPackageWithMinimum.Validate(), - (newSubscriptionPackageWithAllocation) => - newSubscriptionPackageWithAllocation.Validate(), - (newSubscriptionUnitWithPercent) => newSubscriptionUnitWithPercent.Validate(), - (newSubscriptionMatrixWithAllocation) => newSubscriptionMatrixWithAllocation.Validate(), - (tieredWithProration) => tieredWithProration.Validate(), - (newSubscriptionUnitWithProration) => newSubscriptionUnitWithProration.Validate(), - (newSubscriptionGroupedAllocation) => newSubscriptionGroupedAllocation.Validate(), - (newSubscriptionBulkWithProration) => newSubscriptionBulkWithProration.Validate(), - (newSubscriptionGroupedWithProratedMinimum) => - newSubscriptionGroupedWithProratedMinimum.Validate(), - (newSubscriptionGroupedWithMeteredMinimum) => - newSubscriptionGroupedWithMeteredMinimum.Validate(), - (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), - (newSubscriptionMatrixWithDisplayName) => - newSubscriptionMatrixWithDisplayName.Validate(), - (newSubscriptionGroupedTieredPackage) => newSubscriptionGroupedTieredPackage.Validate(), - (newSubscriptionMaxGroupTieredPackage) => - newSubscriptionMaxGroupTieredPackage.Validate(), - (newSubscriptionScalableMatrixWithUnitPricing) => - newSubscriptionScalableMatrixWithUnitPricing.Validate(), - (newSubscriptionScalableMatrixWithTieredPricing) => - newSubscriptionScalableMatrixWithTieredPricing.Validate(), - (newSubscriptionCumulativeGroupedBulk) => - newSubscriptionCumulativeGroupedBulk.Validate(), - (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), - (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), - (percent) => percent.Validate(), - (eventOutput) => eventOutput.Validate() - ); - } - - public virtual bool Equals(ReplacePricePrice? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class ReplacePricePriceConverter : JsonConverter -{ - public override ReplacePricePrice? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try - { - modelType = element.GetProperty("model_type").GetString(); - } - catch - { - modelType = null; - } - - switch (modelType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk_with_filters": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "threshold_total_amount": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_with_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_tiered": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_package_with_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "package_with_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "unit_with_percent": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix_with_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "unit_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_prorated_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_metered_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix_with_display_name": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "max_group_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_unit_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "scalable_matrix_with_tiered_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_bulk": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "cumulative_grouped_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum_composite": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "percent": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "event_output": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new ReplacePricePrice(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - ReplacePricePrice? value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value?.Json, options); - } -} - -[JsonConverter( - typeof(JsonModelConverter< - ReplacePricePriceBulkWithFilters, - ReplacePricePriceBulkWithFiltersFromRaw - >) -)] -public sealed record class ReplacePricePriceBulkWithFilters : JsonModel -{ - /// - /// Configuration for bulk_with_filters pricing - /// - public required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); - } - init { this._rawData.Set("bulk_with_filters_config", value); } - } - - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); - } - init { this._rawData.Set("cadence", value); } - } - - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } - } - - /// - /// The pricing model type - /// - public JsonElement ModelType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } - } - - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } - - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate + public T Match( + System::Func newSubscriptionUnit, + System::Func newSubscriptionTiered, + System::Func newSubscriptionBulk, + System::Func bulkWithFilters, + System::Func newSubscriptionPackage, + System::Func newSubscriptionMatrix, + System::Func< + NewSubscriptionThresholdTotalAmountPrice, + T + > newSubscriptionThresholdTotalAmount, + System::Func newSubscriptionTieredPackage, + System::Func newSubscriptionTieredWithMinimum, + System::Func newSubscriptionGroupedTiered, + System::Func< + NewSubscriptionTieredPackageWithMinimumPrice, + T + > newSubscriptionTieredPackageWithMinimum, + System::Func< + NewSubscriptionPackageWithAllocationPrice, + T + > newSubscriptionPackageWithAllocation, + System::Func newSubscriptionUnitWithPercent, + System::Func< + NewSubscriptionMatrixWithAllocationPrice, + T + > newSubscriptionMatrixWithAllocation, + System::Func tieredWithProration, + System::Func newSubscriptionUnitWithProration, + System::Func newSubscriptionGroupedAllocation, + System::Func newSubscriptionBulkWithProration, + System::Func< + NewSubscriptionGroupedWithProratedMinimumPrice, + T + > newSubscriptionGroupedWithProratedMinimum, + System::Func< + NewSubscriptionGroupedWithMeteredMinimumPrice, + T + > newSubscriptionGroupedWithMeteredMinimum, + System::Func groupedWithMinMaxThresholds, + System::Func< + NewSubscriptionMatrixWithDisplayNamePrice, + T + > newSubscriptionMatrixWithDisplayName, + System::Func< + NewSubscriptionGroupedTieredPackagePrice, + T + > newSubscriptionGroupedTieredPackage, + System::Func< + NewSubscriptionMaxGroupTieredPackagePrice, + T + > newSubscriptionMaxGroupTieredPackage, + System::Func< + NewSubscriptionScalableMatrixWithUnitPricingPrice, + T + > newSubscriptionScalableMatrixWithUnitPricing, + System::Func< + NewSubscriptionScalableMatrixWithTieredPricingPrice, + T + > newSubscriptionScalableMatrixWithTieredPricing, + System::Func< + NewSubscriptionCumulativeGroupedBulkPrice, + T + > newSubscriptionCumulativeGroupedBulk, + System::Func cumulativeGroupedAllocation, + System::Func newSubscriptionMinimumComposite, + System::Func percent, + System::Func eventOutput + ) { - get + return this.Value switch { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } + NewSubscriptionUnitPrice value => newSubscriptionUnit(value), + NewSubscriptionTieredPrice value => newSubscriptionTiered(value), + NewSubscriptionBulkPrice value => newSubscriptionBulk(value), + ReplacePricePriceBulkWithFilters value => bulkWithFilters(value), + NewSubscriptionPackagePrice value => newSubscriptionPackage(value), + NewSubscriptionMatrixPrice value => newSubscriptionMatrix(value), + NewSubscriptionThresholdTotalAmountPrice value => newSubscriptionThresholdTotalAmount( + value + ), + NewSubscriptionTieredPackagePrice value => newSubscriptionTieredPackage(value), + NewSubscriptionTieredWithMinimumPrice value => newSubscriptionTieredWithMinimum(value), + NewSubscriptionGroupedTieredPrice value => newSubscriptionGroupedTiered(value), + NewSubscriptionTieredPackageWithMinimumPrice value => + newSubscriptionTieredPackageWithMinimum(value), + NewSubscriptionPackageWithAllocationPrice value => newSubscriptionPackageWithAllocation( + value + ), + NewSubscriptionUnitWithPercentPrice value => newSubscriptionUnitWithPercent(value), + NewSubscriptionMatrixWithAllocationPrice value => newSubscriptionMatrixWithAllocation( + value + ), + ReplacePricePriceTieredWithProration value => tieredWithProration(value), + NewSubscriptionUnitWithProrationPrice value => newSubscriptionUnitWithProration(value), + NewSubscriptionGroupedAllocationPrice value => newSubscriptionGroupedAllocation(value), + NewSubscriptionBulkWithProrationPrice value => newSubscriptionBulkWithProration(value), + NewSubscriptionGroupedWithProratedMinimumPrice value => + newSubscriptionGroupedWithProratedMinimum(value), + NewSubscriptionGroupedWithMeteredMinimumPrice value => + newSubscriptionGroupedWithMeteredMinimum(value), + ReplacePricePriceGroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds( + value + ), + NewSubscriptionMatrixWithDisplayNamePrice value => newSubscriptionMatrixWithDisplayName( + value + ), + NewSubscriptionGroupedTieredPackagePrice value => newSubscriptionGroupedTieredPackage( + value + ), + NewSubscriptionMaxGroupTieredPackagePrice value => newSubscriptionMaxGroupTieredPackage( + value + ), + NewSubscriptionScalableMatrixWithUnitPricingPrice value => + newSubscriptionScalableMatrixWithUnitPricing(value), + NewSubscriptionScalableMatrixWithTieredPricingPrice value => + newSubscriptionScalableMatrixWithTieredPricing(value), + NewSubscriptionCumulativeGroupedBulkPrice value => newSubscriptionCumulativeGroupedBulk( + value + ), + ReplacePricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation( + value + ), + NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), + ReplacePricePricePercent value => percent(value), + ReplacePricePriceEventOutput value => eventOutput(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePrice" + ), + }; } - /// - /// 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); } - } + public static implicit operator ReplacePricePrice(NewSubscriptionUnitPrice value) => new(value); - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); - } - init { this._rawData.Set("currency", value); } - } + public static implicit operator ReplacePricePrice(NewSubscriptionTieredPrice value) => + new(value); - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } + public static implicit operator ReplacePricePrice(NewSubscriptionBulkPrice value) => new(value); - /// - /// An alias for the price. - /// - public string? ExternalPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } - } + public static implicit operator ReplacePricePrice(ReplacePricePriceBulkWithFilters value) => + new(value); - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } - } + public static implicit operator ReplacePricePrice(NewSubscriptionPackagePrice value) => + new(value); - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } - } + public static implicit operator ReplacePricePrice(NewSubscriptionMatrixPrice value) => + new(value); - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } + public static implicit operator ReplacePricePrice( + NewSubscriptionThresholdTotalAmountPrice value + ) => new(value); - /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `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 static implicit operator ReplacePricePrice(NewSubscriptionTieredPackagePrice value) => + new(value); - /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. - /// - public string? ReferenceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); - } - init { this._rawData.Set("reference_id", value); } - } + public static implicit operator ReplacePricePrice( + NewSubscriptionTieredWithMinimumPrice value + ) => new(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 static implicit operator ReplacePricePrice(NewSubscriptionGroupedTieredPrice value) => + new(value); - public ReplacePricePriceBulkWithFilters() - { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } + public static implicit operator ReplacePricePrice( + NewSubscriptionTieredPackageWithMinimumPrice value + ) => new(value); - public ReplacePricePriceBulkWithFilters( - ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters - ) - : base(replacePricePriceBulkWithFilters) { } + public static implicit operator ReplacePricePrice( + NewSubscriptionPackageWithAllocationPrice value + ) => new(value); - public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); + public static implicit operator ReplacePricePrice(NewSubscriptionUnitWithPercentPrice value) => + new(value); - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - } + public static implicit operator ReplacePricePrice( + NewSubscriptionMatrixWithAllocationPrice value + ) => new(value); -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + public static implicit operator ReplacePricePrice(ReplacePricePriceTieredWithProration value) => + new(value); - /// - public static ReplacePricePriceBulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} + public static implicit operator ReplacePricePrice( + NewSubscriptionUnitWithProrationPrice value + ) => new(value); -class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson -{ - /// - public ReplacePricePriceBulkWithFilters FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); -} + public static implicit operator ReplacePricePrice( + NewSubscriptionGroupedAllocationPrice 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( + NewSubscriptionBulkWithProrationPrice 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( + NewSubscriptionGroupedWithProratedMinimumPrice 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( + NewSubscriptionGroupedWithMeteredMinimumPrice value + ) => new(value); - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } + public static implicit operator ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds value + ) => new(value); - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } + public static implicit operator ReplacePricePrice( + NewSubscriptionMatrixWithDisplayNamePrice value + ) => new(value); - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } + public static implicit operator ReplacePricePrice( + NewSubscriptionGroupedTieredPackagePrice value + ) => new(value); -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + public static implicit operator ReplacePricePrice( + NewSubscriptionMaxGroupTieredPackagePrice value + ) => new(value); - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} + public static implicit operator ReplacePricePrice( + NewSubscriptionScalableMatrixWithUnitPricingPrice value + ) => new(value); -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw - : IFromRawJson -{ - /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); -} + public static implicit operator ReplacePricePrice( + NewSubscriptionScalableMatrixWithTieredPricingPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewSubscriptionCumulativeGroupedBulkPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + ReplacePricePriceCumulativeGroupedAllocation value + ) => new(value); -/// -/// 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(NewSubscriptionMinimumCompositePrice value) => + new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePricePercent value) => new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePriceEventOutput value) => + new(value); /// - /// Event property value to match + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// /// - public required string PropertyValue + public override void Validate() { - get + if (this.Value == null) { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePrice" + ); } - init { this._rawData.Set("property_value", value); } - } - - /// - public override void Validate() - { - _ = this.PropertyKey; - _ = this.PropertyValue; + 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() + ); } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } - - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } + public virtual bool Equals(ReplacePricePrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - IReadOnlyDictionary rawData - ) + public override int GetHashCode() { - this._rawData = new(rawData); + return 0; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( - IReadOnlyDictionary rawData - ) + int VariantIndex() { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + 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, + }; } } -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 +sealed class ReplacePricePriceConverter : JsonConverter { - /// - /// Amount per unit - /// - public required string UnitAmount + public override ReplacePricePrice? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - get + var element = JsonSerializer.Deserialize(ref reader, options); + string? modelType; + try { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + modelType = element.GetProperty("model_type").GetString(); } - init { this._rawData.Set("unit_amount", value); } - } - - /// - /// The lower bound for this tier - /// - public string? TierLowerBound - { - get + catch { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); + modelType = null; } - init { this._rawData.Set("tier_lower_bound", value); } - } - /// - public override void Validate() - { - _ = this.UnitAmount; - _ = this.TierLowerBound; - } + switch (modelType) + { + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - ) - : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - [SetsRequiredMembers] - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } -} + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - : IFromRawJson -{ - /// - public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); -} + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersCadenceConverter))] -public enum ReplacePricePriceBulkWithFiltersCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -sealed class ReplacePricePriceBulkWithFiltersCadenceConverter - : JsonConverter -{ - public override ReplacePricePriceBulkWithFiltersCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => ReplacePricePriceBulkWithFiltersCadence.Annual, - "semi_annual" => ReplacePricePriceBulkWithFiltersCadence.SemiAnnual, - "monthly" => ReplacePricePriceBulkWithFiltersCadence.Monthly, - "quarterly" => ReplacePricePriceBulkWithFiltersCadence.Quarterly, - "one_time" => ReplacePricePriceBulkWithFiltersCadence.OneTime, - "custom" => ReplacePricePriceBulkWithFiltersCadence.Custom, - _ => (ReplacePricePriceBulkWithFiltersCadence)(-1), - }; - } + return new(element); + } + case "tiered_package_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public override void Write( - Utf8JsonWriter writer, - ReplacePricePriceBulkWithFiltersCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch + return new(element); + } + case "package_with_allocation": { - ReplacePricePriceBulkWithFiltersCadence.Annual => "annual", - ReplacePricePriceBulkWithFiltersCadence.SemiAnnual => "semi_annual", - ReplacePricePriceBulkWithFiltersCadence.Monthly => "monthly", - ReplacePricePriceBulkWithFiltersCadence.Quarterly => "quarterly", - ReplacePricePriceBulkWithFiltersCadence.OneTime => "one_time", - ReplacePricePriceBulkWithFiltersCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } -[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] -public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase -{ - public object? Value { get; } = null; + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - JsonElement? _element = null; + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public override int GetHashCode() - { - return 0; - } + return new(element); + } + case "cumulative_grouped_bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - switch (conversionRateType) - { - case "unit": + return new(element); + } + 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) + catch (JsonException) { // ignore } return new(element); } - case "tiered": + case "event_output": { 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) + catch (JsonException) { // ignore } @@ -14977,39 +13115,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 +13207,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 +13266,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 +13362,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +13413,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 +13437,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 +13479,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 +13659,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( FrozenDictionary rawData ) { @@ -15458,86 +13667,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 +13748,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( FrozenDictionary rawData ) { @@ -15554,27 +13756,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 +13859,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15600,7 +13868,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15609,7 +13877,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) { this._element = element; } @@ -15618,7 +13886,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement elem /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -15639,7 +13907,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -15659,7 +13927,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -15670,8 +13938,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15691,7 +13959,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" ); } } @@ -15700,7 +13968,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -15711,8 +13979,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15727,16 +13995,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 +14023,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 +14040,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 @@ -15807,12 +14088,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -15829,12 +14108,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -15843,14 +14120,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 +14137,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 +14197,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 +14271,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 +14367,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +14419,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 +14442,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 +14484,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 +14507,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 +14518,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 +14538,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 +14554,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 +14712,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -16358,8 +14720,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16367,20 +14729,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 +14757,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16406,7 +14766,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16415,7 +14775,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -16424,7 +14784,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElem /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -16445,7 +14805,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -16465,7 +14825,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -16476,8 +14836,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16497,7 +14857,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" ); } } @@ -16506,7 +14866,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -16517,8 +14877,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16533,16 +14893,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 +14921,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 +14938,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 @@ -16615,12 +14986,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -16637,12 +15006,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -16651,16 +15018,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 +15035,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 +15169,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 +15265,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +15317,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 +15340,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 +15384,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 +15407,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 +15418,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 +15438,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 +15454,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 +15545,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -17168,8 +15553,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17177,20 +15562,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 +15592,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17216,7 +15601,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17225,7 +15610,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -17234,7 +15619,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElem /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -17255,7 +15640,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -17275,7 +15660,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -17286,8 +15671,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17307,7 +15692,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" ); } } @@ -17316,7 +15701,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -17327,8 +15712,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17343,16 +15728,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 +15756,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 +15775,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 @@ -17425,12 +15823,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -17447,12 +15843,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -17461,7 +15855,7 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -17470,7 +15864,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -17479,51 +15873,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 +16008,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 +16104,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +16156,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 +16179,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 +16223,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 +16246,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 +16257,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 +16277,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 +16293,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 +16431,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17992,7 +16440,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -18001,7 +16449,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -18010,7 +16458,7 @@ public ReplacePricePriceMinimumConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -18031,7 +16479,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -18051,7 +16499,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -18062,8 +16510,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18083,7 +16531,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" ); } } @@ -18092,7 +16540,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -18103,8 +16551,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18119,16 +16567,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 +16595,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 +16614,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 @@ -18199,12 +16662,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -18221,12 +16682,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -18235,14 +16694,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 +16940,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +17010,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -18545,8 +17020,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 +17150,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) { @@ -18760,7 +17241,7 @@ public ReplacePricePricePercentConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -18781,7 +17262,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -18801,7 +17282,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -18812,8 +17293,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18842,7 +17323,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -18853,8 +17334,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18903,10 +17384,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 +17395,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 @@ -18949,12 +17443,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -18971,12 +17463,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -19229,6 +17719,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +17794,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -19300,8 +17804,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 +17965,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 @@ -19548,7 +18058,7 @@ public ReplacePricePriceEventOutputConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -19569,7 +18079,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -19589,7 +18099,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -19600,8 +18110,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19630,7 +18140,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -19641,8 +18151,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19691,10 +18201,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 +18212,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 @@ -19737,12 +18260,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -19759,12 +18280,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Subscriptions/SubscriptionFetchCostsParams.cs b/src/Orb/Models/Subscriptions/SubscriptionFetchCostsParams.cs index 5dfc70260..67229a22c 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionFetchCostsParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionFetchCostsParams.cs @@ -17,11 +17,15 @@ namespace Orb.Models.Subscriptions; /// metric, in usage units rather than a currency). /// /// The semantics of this endpoint exactly mirror those of [fetching a customer's -/// 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). +/// costs](/api-reference/customer/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, @@ -100,24 +107,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] SubscriptionFetchCostsParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionFetchCostsParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + subscriptionID + ); + } + + 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) @@ -139,6 +178,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..ca6279d0b 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, @@ -37,24 +44,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] SubscriptionFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + subscriptionID + ); + } + + 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) @@ -76,4 +115,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Subscriptions/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..b3b4130b2 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, @@ -115,24 +122,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] SubscriptionFetchScheduleParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionFetchScheduleParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + subscriptionID + ); + } + + 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) @@ -154,4 +193,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..523038003 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, @@ -287,24 +294,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] SubscriptionFetchUsageParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionFetchUsageParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + subscriptionID + ); + } + + 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) @@ -326,6 +365,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..9f38b51a0 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, @@ -189,7 +194,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static SubscriptionListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -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..ceec6d9df 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, @@ -248,27 +255,61 @@ IReadOnlyDictionary rawBodyData SubscriptionPriceIntervalsParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionPriceIntervalsParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + subscriptionID + ); + } + + 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) @@ -299,6 +340,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 +395,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 +456,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 +488,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 +592,7 @@ public override void Validate() item.Validate(); } _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; _ = this.MinimumAmount; this.Price?.Validate(); _ = this.PriceID; @@ -534,8 +601,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) { @@ -614,7 +684,7 @@ public StartDate(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -633,14 +703,14 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type with a TRaw of string and a TEnum of BillingCycleRelativeDate>. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickBillingCycleRelative(out var value)) { - /// // `value` is of type `ApiEnum` + /// // `value` is of type `ApiEnum<string, BillingCycleRelativeDate>` /// Console.WriteLine(value); /// } /// @@ -657,7 +727,7 @@ public bool TryPickBillingCycleRelative( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -668,8 +738,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -696,7 +766,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -707,8 +777,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -752,10 +822,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 +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 + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class StartDateConverter : JsonConverter @@ -793,7 +876,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) { @@ -870,7 +956,7 @@ public Discount(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -891,7 +977,7 @@ public bool TryPickAmount([NotNullWhen(true)] out 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -912,7 +998,7 @@ public bool TryPickPercentage([NotNullWhen(true)] out Percentage? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -932,7 +1018,7 @@ public bool TryPickUsage([NotNullWhen(true)] out Usage? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -943,9 +1029,9 @@ public bool TryPickUsage([NotNullWhen(true)] out Usage? value) /// /// /// instance.Switch( - /// (Amount value) => {...}, - /// (Percentage value) => {...}, - /// (Usage value) => {...} + /// (Amount value) => {...}, + /// (Percentage value) => {...}, + /// (Usage value) => {...} /// ); /// /// @@ -976,7 +1062,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -987,9 +1073,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (Amount value) => {...}, - /// (Percentage value) => {...}, - /// (Usage value) => {...} + /// (Amount value) => {...}, + /// (Percentage value) => {...}, + /// (Usage value) => {...} /// ); /// /// @@ -1009,14 +1095,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 +1124,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 +1135,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 @@ -1083,12 +1180,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1102,12 +1197,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1121,12 +1214,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1135,16 +1226,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 +1278,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 +1367,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 +1451,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) { @@ -1440,7 +1536,7 @@ public EndDate(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1459,14 +1555,14 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type with a TRaw of string and a TEnum of BillingCycleRelativeDate>. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickBillingCycleRelative(out var value)) { - /// // `value` is of type `ApiEnum` + /// // `value` is of type `ApiEnum<string, BillingCycleRelativeDate>` /// Console.WriteLine(value); /// } /// @@ -1483,7 +1579,7 @@ public bool TryPickBillingCycleRelative( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1494,8 +1590,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -1522,7 +1618,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1533,8 +1629,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -1578,10 +1674,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 +1685,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 +1728,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 +1748,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 +1787,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 +1806,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 +1815,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 +1877,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 +1917,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 +1957,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 +1997,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 +2037,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 +2077,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 +2117,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 +2157,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 +2197,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 +2237,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 +2277,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 +2317,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 +2324,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 +2538,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; @@ -2434,7 +2565,7 @@ public PriceModel(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2455,7 +2586,7 @@ public bool TryPickNewFloatingUnit([NotNullWhen(true)] out NewFloatingUnitPrice? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2476,7 +2607,7 @@ public bool TryPickNewFloatingTiered([NotNullWhen(true)] out NewFloatingTieredPr /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2497,7 +2628,7 @@ public bool TryPickNewFloatingBulk([NotNullWhen(true)] out NewFloatingBulkPrice? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2518,7 +2649,7 @@ public bool TryPickBulkWithFilters([NotNullWhen(true)] out PriceModelBulkWithFil /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2539,7 +2670,7 @@ public bool TryPickNewFloatingPackage([NotNullWhen(true)] out NewFloatingPackage /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2560,7 +2691,7 @@ public bool TryPickNewFloatingMatrix([NotNullWhen(true)] out NewFloatingMatrixPr /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2583,7 +2714,7 @@ public bool TryPickNewFloatingThresholdTotalAmount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2606,7 +2737,7 @@ public bool TryPickNewFloatingTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2629,7 +2760,7 @@ public bool TryPickNewFloatingTieredWithMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2652,7 +2783,7 @@ public bool TryPickNewFloatingGroupedTiered( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2675,7 +2806,7 @@ public bool TryPickNewFloatingTieredPackageWithMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2698,7 +2829,7 @@ public bool TryPickNewFloatingPackageWithAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2721,7 +2852,7 @@ public bool TryPickNewFloatingUnitWithPercent( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2744,7 +2875,7 @@ public bool TryPickNewFloatingMatrixWithAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2767,7 +2898,7 @@ public bool TryPickNewFloatingTieredWithProration( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2790,7 +2921,7 @@ public bool TryPickNewFloatingUnitWithProration( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2813,7 +2944,7 @@ public bool TryPickNewFloatingGroupedAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2836,7 +2967,7 @@ public bool TryPickNewFloatingBulkWithProration( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2859,7 +2990,7 @@ public bool TryPickNewFloatingGroupedWithProratedMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2882,7 +3013,7 @@ public bool TryPickNewFloatingGroupedWithMeteredMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2905,7 +3036,7 @@ public bool TryPickGroupedWithMinMaxThresholds( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2928,7 +3059,7 @@ public bool TryPickNewFloatingMatrixWithDisplayName( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2951,7 +3082,7 @@ public bool TryPickNewFloatingGroupedTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2974,7 +3105,7 @@ public bool TryPickNewFloatingMaxGroupTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2997,7 +3128,7 @@ public bool TryPickNewFloatingScalableMatrixWithUnitPricing( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3020,7 +3151,7 @@ public bool TryPickNewFloatingScalableMatrixWithTieredPricing( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3043,7 +3174,7 @@ public bool TryPickNewFloatingCumulativeGroupedBulk( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3062,32 +3193,11 @@ 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 . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3110,7 +3220,7 @@ public bool TryPickNewFloatingMinimumComposite( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3131,7 +3241,7 @@ public bool TryPickPercent([NotNullWhen(true)] out PriceModelPercent? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3151,7 +3261,7 @@ public bool TryPickEventOutput([NotNullWhen(true)] out PriceModelEventOutput? va /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -3162,38 +3272,37 @@ public bool TryPickEventOutput([NotNullWhen(true)] out PriceModelEventOutput? va /// /// /// instance.Switch( - /// (NewFloatingUnitPrice value) => {...}, - /// (NewFloatingTieredPrice value) => {...}, - /// (NewFloatingBulkPrice value) => {...}, - /// (PriceModelBulkWithFilters value) => {...}, - /// (NewFloatingPackagePrice value) => {...}, - /// (NewFloatingMatrixPrice value) => {...}, - /// (NewFloatingThresholdTotalAmountPrice value) => {...}, - /// (NewFloatingTieredPackagePrice value) => {...}, - /// (NewFloatingTieredWithMinimumPrice value) => {...}, - /// (NewFloatingGroupedTieredPrice value) => {...}, - /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, - /// (NewFloatingPackageWithAllocationPrice value) => {...}, - /// (NewFloatingUnitWithPercentPrice value) => {...}, - /// (NewFloatingMatrixWithAllocationPrice value) => {...}, - /// (NewFloatingTieredWithProrationPrice value) => {...}, - /// (NewFloatingUnitWithProrationPrice value) => {...}, - /// (NewFloatingGroupedAllocationPrice value) => {...}, - /// (NewFloatingBulkWithProrationPrice value) => {...}, - /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, - /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (PriceModelGroupedWithMinMaxThresholds value) => {...}, - /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, - /// (NewFloatingGroupedTieredPackagePrice value) => {...}, - /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, - /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (PriceModelCumulativeGroupedAllocation value) => {...}, - /// (PriceModelMinimum value) => {...}, - /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (PriceModelPercent value) => {...}, - /// (PriceModelEventOutput value) => {...} + /// (NewFloatingUnitPrice value) => {...}, + /// (NewFloatingTieredPrice value) => {...}, + /// (NewFloatingBulkPrice value) => {...}, + /// (PriceModelBulkWithFilters value) => {...}, + /// (NewFloatingPackagePrice value) => {...}, + /// (NewFloatingMatrixPrice value) => {...}, + /// (NewFloatingThresholdTotalAmountPrice value) => {...}, + /// (NewFloatingTieredPackagePrice value) => {...}, + /// (NewFloatingTieredWithMinimumPrice value) => {...}, + /// (NewFloatingGroupedTieredPrice value) => {...}, + /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, + /// (NewFloatingPackageWithAllocationPrice value) => {...}, + /// (NewFloatingUnitWithPercentPrice value) => {...}, + /// (NewFloatingMatrixWithAllocationPrice value) => {...}, + /// (NewFloatingTieredWithProrationPrice value) => {...}, + /// (NewFloatingUnitWithProrationPrice value) => {...}, + /// (NewFloatingGroupedAllocationPrice value) => {...}, + /// (NewFloatingBulkWithProrationPrice value) => {...}, + /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, + /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, + /// (PriceModelGroupedWithMinMaxThresholds value) => {...}, + /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, + /// (NewFloatingGroupedTieredPackagePrice value) => {...}, + /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, + /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, + /// (PriceModelCumulativeGroupedAllocation value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (PriceModelPercent value) => {...}, + /// (PriceModelEventOutput value) => {...} /// ); /// /// @@ -3227,7 +3336,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 +3427,6 @@ public void Switch( case PriceModelCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case PriceModelMinimum value: - minimum(value); - break; case NewFloatingMinimumCompositePrice value: newFloatingMinimumComposite(value); break; @@ -3340,7 +3445,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -3351,38 +3456,37 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewFloatingUnitPrice value) => {...}, - /// (NewFloatingTieredPrice value) => {...}, - /// (NewFloatingBulkPrice value) => {...}, - /// (PriceModelBulkWithFilters value) => {...}, - /// (NewFloatingPackagePrice value) => {...}, - /// (NewFloatingMatrixPrice value) => {...}, - /// (NewFloatingThresholdTotalAmountPrice value) => {...}, - /// (NewFloatingTieredPackagePrice value) => {...}, - /// (NewFloatingTieredWithMinimumPrice value) => {...}, - /// (NewFloatingGroupedTieredPrice value) => {...}, - /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, - /// (NewFloatingPackageWithAllocationPrice value) => {...}, - /// (NewFloatingUnitWithPercentPrice value) => {...}, - /// (NewFloatingMatrixWithAllocationPrice value) => {...}, - /// (NewFloatingTieredWithProrationPrice value) => {...}, - /// (NewFloatingUnitWithProrationPrice value) => {...}, - /// (NewFloatingGroupedAllocationPrice value) => {...}, - /// (NewFloatingBulkWithProrationPrice value) => {...}, - /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, - /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (PriceModelGroupedWithMinMaxThresholds value) => {...}, - /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, - /// (NewFloatingGroupedTieredPackagePrice value) => {...}, - /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, - /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (PriceModelCumulativeGroupedAllocation value) => {...}, - /// (PriceModelMinimum value) => {...}, - /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (PriceModelPercent value) => {...}, - /// (PriceModelEventOutput value) => {...} + /// (NewFloatingUnitPrice value) => {...}, + /// (NewFloatingTieredPrice value) => {...}, + /// (NewFloatingBulkPrice value) => {...}, + /// (PriceModelBulkWithFilters value) => {...}, + /// (NewFloatingPackagePrice value) => {...}, + /// (NewFloatingMatrixPrice value) => {...}, + /// (NewFloatingThresholdTotalAmountPrice value) => {...}, + /// (NewFloatingTieredPackagePrice value) => {...}, + /// (NewFloatingTieredWithMinimumPrice value) => {...}, + /// (NewFloatingGroupedTieredPrice value) => {...}, + /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, + /// (NewFloatingPackageWithAllocationPrice value) => {...}, + /// (NewFloatingUnitWithPercentPrice value) => {...}, + /// (NewFloatingMatrixWithAllocationPrice value) => {...}, + /// (NewFloatingTieredWithProrationPrice value) => {...}, + /// (NewFloatingUnitWithProrationPrice value) => {...}, + /// (NewFloatingGroupedAllocationPrice value) => {...}, + /// (NewFloatingBulkWithProrationPrice value) => {...}, + /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, + /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, + /// (PriceModelGroupedWithMinMaxThresholds value) => {...}, + /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, + /// (NewFloatingGroupedTieredPackagePrice value) => {...}, + /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, + /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, + /// (PriceModelCumulativeGroupedAllocation value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (PriceModelPercent value) => {...}, + /// (PriceModelEventOutput value) => {...} /// ); /// /// @@ -3431,7 +3535,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 +3577,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 +3661,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 +3717,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 +3734,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 @@ -3669,12 +3810,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3691,12 +3830,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3713,12 +3850,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3735,12 +3870,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3757,12 +3890,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3779,12 +3910,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3802,12 +3931,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3824,12 +3951,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3847,12 +3972,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3869,12 +3992,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3892,12 +4013,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3915,12 +4034,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3937,12 +4054,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3960,12 +4075,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3983,12 +4096,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4006,12 +4117,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4029,12 +4138,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4052,12 +4159,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4075,12 +4180,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4098,12 +4201,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4121,12 +4222,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4144,12 +4243,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4167,12 +4264,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4190,12 +4285,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4213,12 +4306,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4236,12 +4327,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4259,12 +4348,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4282,34 +4369,10 @@ JsonSerializerOptions options ); if (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) + catch (JsonException) { // ignore } @@ -4326,12 +4389,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4348,12 +4409,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4370,12 +4429,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4627,6 +4684,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +4745,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4683,8 +4754,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 +4860,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 +4947,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 +5036,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 @@ -5108,7 +5191,7 @@ public PriceModelBulkWithFiltersConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5129,7 +5212,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5149,7 +5232,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -5160,8 +5243,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5190,7 +5273,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -5201,8 +5284,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5251,10 +5334,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 +5345,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 @@ -5297,12 +5393,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5319,12 +5413,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5579,6 +5671,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +5732,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -5635,10 +5741,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 +5917,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 @@ -5896,7 +6008,7 @@ public PriceModelGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement ele /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5917,7 +6029,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5937,7 +6049,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -5948,8 +6060,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5978,7 +6090,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -5989,8 +6101,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6039,10 +6151,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 +6162,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 @@ -6085,12 +6210,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6107,12 +6230,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6367,6 +6488,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +6549,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -6423,10 +6558,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 +6734,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 @@ -6684,7 +6825,7 @@ public PriceModelCumulativeGroupedAllocationConversionRateConfig(JsonElement ele /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6705,7 +6846,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6725,7 +6866,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -6736,8 +6877,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6766,7 +6907,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -6777,8 +6918,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6827,10 +6968,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 +6979,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 @@ -6873,12 +7027,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6895,12 +7047,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6924,18 +7074,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 +7118,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,752 +7145,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 PriceModelPercentPercentConfig 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 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 - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("percent_config"); - } - init { this._rawData.Set("percent_config", value); } + init { this._rawData.Set("percent_config", value); } } /// @@ -7897,6 +7298,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +7354,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7948,8 +7363,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 +7491,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) { @@ -8160,7 +7581,7 @@ public PriceModelPercentConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8181,7 +7602,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8201,7 +7622,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -8212,8 +7633,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8242,7 +7663,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -8253,8 +7674,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8303,10 +7724,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 +7735,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 @@ -8349,12 +7783,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8371,12 +7803,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8626,6 +8056,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +8117,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -8682,8 +8126,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 +8286,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) { @@ -8927,7 +8377,7 @@ public PriceModelEventOutputConversionRateConfig(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8948,7 +8398,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8968,7 +8418,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -8979,8 +8429,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9009,7 +8459,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -9020,8 +8470,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9070,10 +8520,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 +8531,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 @@ -9116,12 +8579,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9138,12 +8599,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9252,10 +8711,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 @@ -9350,7 +8812,7 @@ public SubscriptionPriceIntervalsParamsAddAdjustmentStartDate(JsonElement elemen /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9369,14 +8831,14 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type with a TRaw of string and a TEnum of BillingCycleRelativeDate>. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickBillingCycleRelative(out var value)) { - /// // `value` is of type `ApiEnum` + /// // `value` is of type `ApiEnum<string, BillingCycleRelativeDate>` /// Console.WriteLine(value); /// } /// @@ -9393,7 +8855,7 @@ public bool TryPickBillingCycleRelative( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -9404,8 +8866,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -9434,7 +8896,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -9445,8 +8907,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -9499,10 +8961,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 +8972,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 +9016,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) { @@ -9664,7 +9142,7 @@ public SubscriptionPriceIntervalsParamsAddAdjustmentAdjustment(JsonElement eleme /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9685,7 +9163,7 @@ public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDi /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9706,7 +9184,7 @@ public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9727,7 +9205,7 @@ public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9748,7 +9226,7 @@ public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9768,7 +9246,7 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -9779,11 +9257,11 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// @@ -9824,7 +9302,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -9835,11 +9313,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// @@ -9912,10 +9390,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 +9401,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 @@ -9958,12 +9452,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9980,12 +9472,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -10002,12 +9492,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -10021,12 +9509,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -10040,12 +9526,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -10120,7 +9604,7 @@ public SubscriptionPriceIntervalsParamsAddAdjustmentEndDate(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -10139,14 +9623,14 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type with a TRaw of string and a TEnum of BillingCycleRelativeDate>. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickBillingCycleRelative(out var value)) { - /// // `value` is of type `ApiEnum` + /// // `value` is of type `ApiEnum<string, BillingCycleRelativeDate>` /// Console.WriteLine(value); /// } /// @@ -10163,7 +9647,7 @@ public bool TryPickBillingCycleRelative( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -10174,8 +9658,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -10204,7 +9688,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -10215,8 +9699,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -10269,10 +9753,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 +9764,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 +9808,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 +9929,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 +10009,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) { @@ -10573,7 +10099,7 @@ public EditEndDate(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -10592,14 +10118,14 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type with a TRaw of string and a TEnum of BillingCycleRelativeDate>. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickBillingCycleRelative(out var value)) { - /// // `value` is of type `ApiEnum` + /// // `value` is of type `ApiEnum<string, BillingCycleRelativeDate>` /// Console.WriteLine(value); /// } /// @@ -10616,7 +10142,7 @@ public bool TryPickBillingCycleRelative( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -10627,8 +10153,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -10655,7 +10181,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -10666,8 +10192,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -10711,10 +10237,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 +10248,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 +10291,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 +10357,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) { @@ -10896,7 +10441,7 @@ public EditStartDate(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -10915,14 +10460,14 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type with a TRaw of string and a TEnum of BillingCycleRelativeDate>. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickBillingCycleRelative(out var value)) { - /// // `value` is of type `ApiEnum` + /// // `value` is of type `ApiEnum<string, BillingCycleRelativeDate>` /// Console.WriteLine(value); /// } /// @@ -10939,7 +10484,7 @@ public bool TryPickBillingCycleRelative( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -10950,8 +10495,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -10980,7 +10525,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -10991,8 +10536,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -11039,10 +10584,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 +10595,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 +10638,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 +10723,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) { @@ -11245,7 +10809,7 @@ public EditAdjustmentEndDate(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -11264,14 +10828,14 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type with a TRaw of string and a TEnum of BillingCycleRelativeDate>. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickBillingCycleRelative(out var value)) { - /// // `value` is of type `ApiEnum` + /// // `value` is of type `ApiEnum<string, BillingCycleRelativeDate>` /// Console.WriteLine(value); /// } /// @@ -11288,7 +10852,7 @@ public bool TryPickBillingCycleRelative( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -11299,8 +10863,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -11329,7 +10893,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -11340,8 +10904,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -11392,10 +10956,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 +10967,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 +11010,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) { @@ -11499,7 +11079,7 @@ public EditAdjustmentStartDate(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -11518,14 +11098,14 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type with a TRaw of string and a TEnum of BillingCycleRelativeDate>. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickBillingCycleRelative(out var value)) { - /// // `value` is of type `ApiEnum` + /// // `value` is of type `ApiEnum<string, BillingCycleRelativeDate>` /// Console.WriteLine(value); /// } /// @@ -11542,7 +11122,7 @@ public bool TryPickBillingCycleRelative( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -11553,8 +11133,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -11583,7 +11163,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -11594,8 +11174,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -11646,10 +11226,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 +11237,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 +11280,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..d939a2336 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, @@ -119,29 +126,63 @@ IReadOnlyDictionary rawBodyData SubscriptionRedeemCouponParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionRedeemCouponParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + subscriptionID ); } + 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 +211,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..cb26f1600 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs @@ -50,9 +50,9 @@ namespace Orb.Models.Subscriptions; /// subscription when you schedule the plan change. This is useful when a customer /// has prices that differ from the default prices for a specific plan. /// -/// This feature is only available for accounts that have migrated to -/// Subscription Overrides Version 2. You can find your Subscription Overrides Version -/// at the bottom of your [Plans page](https://app.withorb.com/plans) +/// <Note> This feature is only available for accounts that have migrated +/// to Subscription Overrides Version 2. You can find your Subscription Overrides +/// Version at the bottom of your [Plans page](https://app.withorb.com/plans) </Note> /// /// ### Adding Prices /// @@ -143,8 +143,8 @@ namespace Orb.Models.Subscriptions; /// /// ## Price overrides (DEPRECATED) /// -/// Price overrides are being phased out in favor adding/removing/replacing -/// prices. (See [Customize your customer's subscriptions](/api-reference/subscription/schedule-plan-change)) +/// <Note> Price overrides are being phased out in favor adding/removing/replacing +/// prices. (See [Customize your customer's subscriptions](/api-reference/subscription/schedule-plan-change)) </Note> /// /// Price overrides are used to update some or all prices in a plan for the /// specific subscription being created. This is useful when a new customer has negotiated @@ -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, @@ -639,27 +646,61 @@ IReadOnlyDictionary rawBodyData SubscriptionSchedulePlanChangeParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionSchedulePlanChangeParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + subscriptionID + ); + } + + 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) @@ -690,6 +731,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 +864,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 @@ -968,7 +1017,7 @@ public SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment(JsonElement e /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -989,7 +1038,7 @@ public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDi /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1010,7 +1059,7 @@ public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1031,7 +1080,7 @@ public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1052,7 +1101,7 @@ public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1072,7 +1121,7 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1083,11 +1132,11 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// @@ -1128,7 +1177,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1139,11 +1188,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// @@ -1216,10 +1265,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 +1278,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 @@ -1262,12 +1329,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1284,12 +1349,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1306,12 +1369,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1325,12 +1386,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1344,12 +1403,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1457,6 +1514,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 +1618,7 @@ public override void Validate() _ = this.EndDate; _ = this.ExternalPriceID; _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; _ = this.MinimumAmount; _ = this.PlanPhaseOrder; this.Price?.Validate(); @@ -1548,10 +1628,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 +1723,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 +1763,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 +1803,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 +1843,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 +1883,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 +1923,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 +1963,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 +2005,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 +2045,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 +2085,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 +2125,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 +2166,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 +2173,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 +2246,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 +2505,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 @@ -2440,7 +2541,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePrice(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2461,7 +2562,7 @@ public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUn /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2484,7 +2585,7 @@ public bool TryPickNewSubscriptionTiered( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2505,7 +2606,7 @@ public bool TryPickNewSubscriptionBulk([NotNullWhen(true)] out NewSubscriptionBu /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2529,7 +2630,7 @@ out SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2552,7 +2653,7 @@ public bool TryPickNewSubscriptionPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2575,7 +2676,7 @@ public bool TryPickNewSubscriptionMatrix( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2598,7 +2699,7 @@ public bool TryPickNewSubscriptionThresholdTotalAmount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2621,7 +2722,7 @@ public bool TryPickNewSubscriptionTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2644,7 +2745,7 @@ public bool TryPickNewSubscriptionTieredWithMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2667,7 +2768,7 @@ public bool TryPickNewSubscriptionGroupedTiered( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2690,7 +2791,7 @@ public bool TryPickNewSubscriptionTieredPackageWithMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2713,7 +2814,7 @@ public bool TryPickNewSubscriptionPackageWithAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2736,7 +2837,7 @@ public bool TryPickNewSubscriptionUnitWithPercent( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2759,7 +2860,7 @@ public bool TryPickNewSubscriptionMatrixWithAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2783,7 +2884,7 @@ out SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration? 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2806,7 +2907,7 @@ public bool TryPickNewSubscriptionUnitWithProration( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2829,7 +2930,7 @@ public bool TryPickNewSubscriptionGroupedAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2852,7 +2953,7 @@ public bool TryPickNewSubscriptionBulkWithProration( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2875,7 +2976,7 @@ public bool TryPickNewSubscriptionGroupedWithProratedMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2898,7 +2999,7 @@ public bool TryPickNewSubscriptionGroupedWithMeteredMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2924,7 +3025,7 @@ out SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2947,7 +3048,7 @@ public bool TryPickNewSubscriptionMatrixWithDisplayName( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2970,7 +3071,7 @@ public bool TryPickNewSubscriptionGroupedTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2993,7 +3094,7 @@ public bool TryPickNewSubscriptionMaxGroupTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3016,7 +3117,7 @@ public bool TryPickNewSubscriptionScalableMatrixWithUnitPricing( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3039,7 +3140,7 @@ public bool TryPickNewSubscriptionScalableMatrixWithTieredPricing( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3062,7 +3163,7 @@ public bool TryPickNewSubscriptionCumulativeGroupedBulk( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3084,34 +3185,11 @@ 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 . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3134,7 +3212,7 @@ public bool TryPickNewSubscriptionMinimumComposite( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3157,7 +3235,7 @@ public bool TryPickPercent( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -3179,7 +3257,7 @@ public bool TryPickEventOutput( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -3190,38 +3268,37 @@ public bool TryPickEventOutput( /// /// /// instance.Switch( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, - /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, - /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePricePercent value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value) => {...} + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration value) => {...}, + /// (NewSubscriptionUnitWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedAllocationPrice value) => {...}, + /// (NewSubscriptionBulkWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, + /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, + /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePricePercent value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value) => {...} /// ); /// /// @@ -3255,7 +3332,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 +3423,6 @@ public void Switch( case SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value: - minimum(value); - break; case NewSubscriptionMinimumCompositePrice value: newSubscriptionMinimumComposite(value); break; @@ -3370,7 +3443,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -3381,38 +3454,37 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, - /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, - /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePricePercent value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value) => {...} + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration value) => {...}, + /// (NewSubscriptionUnitWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedAllocationPrice value) => {...}, + /// (NewSubscriptionBulkWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, + /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, + /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePricePercent value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value) => {...} /// ); /// /// @@ -3494,7 +3566,6 @@ public T Match( SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation, T > cumulativeGroupedAllocation, - System::Func minimum, System::Func newSubscriptionMinimumComposite, System::Func percent, System::Func eventOutput @@ -3553,7 +3624,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 +3747,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 +3815,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 +3832,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 @@ -3802,12 +3909,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3824,12 +3929,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3846,12 +3949,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3869,12 +3970,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3891,12 +3990,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3913,12 +4010,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3936,12 +4031,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3959,12 +4052,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3982,12 +4073,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4005,12 +4094,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4028,12 +4115,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4051,12 +4136,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4074,12 +4157,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4097,12 +4178,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4120,12 +4199,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4143,12 +4220,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4166,12 +4241,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4189,12 +4262,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4212,12 +4283,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4235,12 +4304,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4258,12 +4325,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4281,12 +4346,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4304,12 +4367,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4327,12 +4388,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4350,12 +4409,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4373,12 +4430,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4396,12 +4451,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4419,35 +4472,10 @@ JsonSerializerOptions options ); if (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) + catch (JsonException) { // ignore } @@ -4465,12 +4493,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4488,12 +4514,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4511,12 +4535,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4779,6 +4801,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +4876,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -4850,10 +4886,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 +4999,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 +5095,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 +5191,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 @@ -5324,7 +5372,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5345,7 +5393,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -5365,7 +5413,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -5376,8 +5424,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5406,7 +5454,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -5417,8 +5465,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5469,10 +5517,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 +5528,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 @@ -5515,12 +5576,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5537,12 +5596,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5807,6 +5864,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +5939,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -5878,10 +5949,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 +6116,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 +6221,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 @@ -6239,7 +6319,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6260,7 +6340,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -6280,7 +6360,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -6291,8 +6371,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6321,7 +6401,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -6332,8 +6412,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6384,10 +6464,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 +6475,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 @@ -6430,12 +6523,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6452,12 +6543,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6722,6 +6811,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +6886,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -6793,10 +6896,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 +7097,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 @@ -7086,7 +7195,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7107,7 +7216,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7127,7 +7236,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -7138,8 +7247,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7168,7 +7277,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -7179,8 +7288,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7231,10 +7340,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 +7351,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 @@ -7277,12 +7399,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7299,12 +7419,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7569,6 +7687,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +7762,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -7640,10 +7772,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 +7973,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 @@ -7933,7 +8071,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7954,7 +8092,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -7974,7 +8112,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -7985,8 +8123,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8015,7 +8153,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -8026,8 +8164,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8078,10 +8216,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 +8227,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 @@ -8124,12 +8275,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8146,12 +8295,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8179,25 +8326,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 +8363,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,9 +8390,24 @@ 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 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 { get { @@ -8316,12 +8463,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 +8559,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +8612,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 +8629,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 +8666,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8511,20 +8675,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 +8698,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 +8709,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 +8731,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 +8751,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 +8800,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( FrozenDictionary rawData ) { @@ -8663,8 +8808,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8672,31 +8817,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 +8857,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8723,7 +8866,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8732,7 +8875,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( JsonElement element ) { @@ -8743,7 +8886,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8764,7 +8907,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -8784,7 +8927,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -8795,8 +8938,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8816,7 +8959,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" ); } } @@ -8825,7 +8968,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -8836,8 +8979,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8852,16 +8995,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 +9023,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 +9042,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 @@ -8934,12 +9090,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8956,12 +9110,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8970,7 +9122,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( element ); } @@ -8979,7 +9131,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -8989,30 +9141,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 +9219,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 +9278,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 +9374,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +9426,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 +9449,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 +9486,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9321,20 +9495,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 +9520,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 +9531,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), - }; - } - - public override void Write( + 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 +9555,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 +9577,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 +9657,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( FrozenDictionary rawData ) { @@ -9451,8 +9665,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9460,29 +9674,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 +9716,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9509,7 +9725,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9518,7 +9734,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( JsonElement element ) { @@ -9529,7 +9745,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9550,7 +9766,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -9570,7 +9786,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -9581,8 +9797,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9602,7 +9818,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" ); } } @@ -9611,7 +9827,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -9622,8 +9838,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9638,16 +9854,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 +9882,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 +9901,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 @@ -9720,12 +9949,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9742,12 +9969,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -9756,7 +9981,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( element ); } @@ -9765,7 +9990,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -9773,329 +9998,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 - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); - } - init { this._rawData.Set("cadence", value); } - } + Unchanged, + PlanChangeDate, + StartOfMonth, +} - /// - /// Configuration for event_output pricing - /// - public required SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig EventOutputConfig +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( - "event_output_config" - ); - } - init { this._rawData.Set("event_output_config", value); } + "unchanged" => BillingCycleAlignment.Unchanged, + "plan_change_date" => BillingCycleAlignment.PlanChangeDate, + "start_of_month" => BillingCycleAlignment.StartOfMonth, + _ => (BillingCycleAlignment)(-1), + }; } - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID + public override void Write( + Utf8JsonWriter writer, + BillingCycleAlignment value, + JsonSerializerOptions options + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", 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 pricing model type + /// The id of the adjustment to remove on the subscription. /// - public JsonElement ModelType + public required string AdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNotNullClass("adjustment_id"); } - init { this._rawData.Set("model_type", value); } + init { this._rawData.Set("adjustment_id", value); } } - /// - /// The name of the price. - /// - public required string Name + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } + _ = this.AdjustmentID; } - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment() { } - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( + SubscriptionSchedulePlanChangeParamsRemoveAdjustment subscriptionSchedulePlanChangeParamsRemoveAdjustment + ) + : base(subscriptionSchedulePlanChangeParamsRemoveAdjustment) { } +#pragma warning restore CS8618 + + 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 +10283,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplaceAdjustment FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -10112,295 +10292,223 @@ 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. + /// 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. + /// 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; } /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -10411,28 +10519,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" ); } } @@ -10441,7 +10564,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -10452,33 +10575,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 +10640,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,245 +10665,308 @@ 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 ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } 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) + catch (JsonException) { // ignore } return new(element); } - default: + case "amount_discount": { - return new SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( - element - ); + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); } - } - } + case "minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public override void Write( - Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} - -/// -/// Reset billing periods to be aligned with the plan change's effective date or start -/// of the month. Defaults to `unchanged` which keeps subscription's existing billing -/// cycle alignment. -/// -[JsonConverter(typeof(BillingCycleAlignmentConverter))] -public enum BillingCycleAlignment -{ - Unchanged, - PlanChangeDate, - StartOfMonth, -} + return new(element); + } + case "maximum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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 +10981,32 @@ 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 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 +11015,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,1864 +11067,1169 @@ public JsonElement Json } } - public string? Currency + public string ItemID { get { - return Match( - newPercentageDiscount: (x) => x.Currency, - newUsageDiscount: (x) => x.Currency, - newAmountDiscount: (x) => x.Currency, - newMinimum: (x) => x.Currency, - newMaximum: (x) => x.Currency + return Match( + newSubscriptionUnit: (x) => x.ItemID, + newSubscriptionTiered: (x) => x.ItemID, + newSubscriptionBulk: (x) => x.ItemID, + bulkWithFilters: (x) => x.ItemID, + newSubscriptionPackage: (x) => x.ItemID, + newSubscriptionMatrix: (x) => x.ItemID, + newSubscriptionThresholdTotalAmount: (x) => x.ItemID, + newSubscriptionTieredPackage: (x) => x.ItemID, + newSubscriptionTieredWithMinimum: (x) => x.ItemID, + newSubscriptionGroupedTiered: (x) => x.ItemID, + newSubscriptionTieredPackageWithMinimum: (x) => x.ItemID, + newSubscriptionPackageWithAllocation: (x) => x.ItemID, + newSubscriptionUnitWithPercent: (x) => x.ItemID, + newSubscriptionMatrixWithAllocation: (x) => x.ItemID, + tieredWithProration: (x) => x.ItemID, + newSubscriptionUnitWithProration: (x) => x.ItemID, + newSubscriptionGroupedAllocation: (x) => x.ItemID, + newSubscriptionBulkWithProration: (x) => x.ItemID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ItemID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ItemID, + groupedWithMinMaxThresholds: (x) => x.ItemID, + newSubscriptionMatrixWithDisplayName: (x) => x.ItemID, + newSubscriptionGroupedTieredPackage: (x) => x.ItemID, + newSubscriptionMaxGroupTieredPackage: (x) => x.ItemID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ItemID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ItemID, + newSubscriptionCumulativeGroupedBulk: (x) => x.ItemID, + cumulativeGroupedAllocation: (x) => x.ItemID, + newSubscriptionMinimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID ); } } - public bool? IsInvoiceLevel + public string Name { get { - return Match( - newPercentageDiscount: (x) => x.IsInvoiceLevel, - newUsageDiscount: (x) => x.IsInvoiceLevel, - newAmountDiscount: (x) => x.IsInvoiceLevel, - newMinimum: (x) => x.IsInvoiceLevel, - newMaximum: (x) => x.IsInvoiceLevel + return Match( + newSubscriptionUnit: (x) => x.Name, + newSubscriptionTiered: (x) => x.Name, + newSubscriptionBulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + newSubscriptionPackage: (x) => x.Name, + newSubscriptionMatrix: (x) => x.Name, + newSubscriptionThresholdTotalAmount: (x) => x.Name, + newSubscriptionTieredPackage: (x) => x.Name, + newSubscriptionTieredWithMinimum: (x) => x.Name, + newSubscriptionGroupedTiered: (x) => x.Name, + newSubscriptionTieredPackageWithMinimum: (x) => x.Name, + newSubscriptionPackageWithAllocation: (x) => x.Name, + newSubscriptionUnitWithPercent: (x) => x.Name, + newSubscriptionMatrixWithAllocation: (x) => x.Name, + tieredWithProration: (x) => x.Name, + newSubscriptionUnitWithProration: (x) => x.Name, + newSubscriptionGroupedAllocation: (x) => x.Name, + newSubscriptionBulkWithProration: (x) => x.Name, + newSubscriptionGroupedWithProratedMinimum: (x) => x.Name, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.Name, + groupedWithMinMaxThresholds: (x) => x.Name, + newSubscriptionMatrixWithDisplayName: (x) => x.Name, + newSubscriptionGroupedTieredPackage: (x) => x.Name, + newSubscriptionMaxGroupTieredPackage: (x) => x.Name, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Name, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Name, + newSubscriptionCumulativeGroupedBulk: (x) => x.Name, + cumulativeGroupedAllocation: (x) => x.Name, + newSubscriptionMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name ); } } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewPercentageDiscount value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewUsageDiscount value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewAmountDiscount value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMinimum value, - JsonElement? element = null - ) + 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( - NewMaximum value, - JsonElement? element = null - ) + public bool? BilledInAdvance { - this.Value = value; - this._element = element; + get + { + return Match( + newSubscriptionUnit: (x) => x.BilledInAdvance, + newSubscriptionTiered: (x) => x.BilledInAdvance, + newSubscriptionBulk: (x) => x.BilledInAdvance, + bulkWithFilters: (x) => x.BilledInAdvance, + newSubscriptionPackage: (x) => x.BilledInAdvance, + newSubscriptionMatrix: (x) => x.BilledInAdvance, + newSubscriptionThresholdTotalAmount: (x) => x.BilledInAdvance, + newSubscriptionTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionTieredWithMinimum: (x) => x.BilledInAdvance, + newSubscriptionGroupedTiered: (x) => x.BilledInAdvance, + newSubscriptionTieredPackageWithMinimum: (x) => x.BilledInAdvance, + newSubscriptionPackageWithAllocation: (x) => x.BilledInAdvance, + newSubscriptionUnitWithPercent: (x) => x.BilledInAdvance, + newSubscriptionMatrixWithAllocation: (x) => x.BilledInAdvance, + tieredWithProration: (x) => x.BilledInAdvance, + newSubscriptionUnitWithProration: (x) => x.BilledInAdvance, + newSubscriptionGroupedAllocation: (x) => x.BilledInAdvance, + newSubscriptionBulkWithProration: (x) => x.BilledInAdvance, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BilledInAdvance, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, + groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, + newSubscriptionMatrixWithDisplayName: (x) => x.BilledInAdvance, + newSubscriptionGroupedTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionMaxGroupTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, + newSubscriptionCumulativeGroupedBulk: (x) => x.BilledInAdvance, + cumulativeGroupedAllocation: (x) => x.BilledInAdvance, + newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); + } } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(JsonElement element) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - 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 + ); + } } - /// - /// Returns true and sets the 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 double? ConversionRate { - 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) - { - 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 - ) + public string? ExternalPriceID { - 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.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 + ); } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was 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 double? FixedPriceQuantity { - 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.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 + ); + } } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewPercentageDiscount value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewUsageDiscount value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewAmountDiscount value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMinimum value - ) => new(value); - - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMaximum value - ) => new(value); - - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// - /// - public override void Validate() + public string? InvoiceGroupingKey { - if (this.Value == null) + get { - throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" + 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 ); } - this.Switch( - (newPercentageDiscount) => newPercentageDiscount.Validate(), - (newUsageDiscount) => newUsageDiscount.Validate(), - (newAmountDiscount) => newAmountDiscount.Validate(), - (newMinimum) => newMinimum.Validate(), - (newMaximum) => newMaximum.Validate() - ); } - public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? other - ) + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } - - public override int GetHashCode() - { - return 0; + 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 + ); + } } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentConverter - : JsonConverter -{ - public override SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + public string? 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 SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(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, - SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value, - JsonSerializerOptions options + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitPrice 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( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters 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( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice? Price + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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 SubscriptionSchedulePlanChangeParamsReplacePrice() { } + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionPackageWithAllocationPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public SubscriptionSchedulePlanChangeParamsReplacePrice( - SubscriptionSchedulePlanChangeParamsReplacePrice subscriptionSchedulePlanChangeParamsReplacePrice + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionUnitWithPercentPrice value, + JsonElement? element = null ) - : base(subscriptionSchedulePlanChangeParamsReplacePrice) { } + { + this.Value = value; + this._element = element; + } - public SubscriptionSchedulePlanChangeParamsReplacePrice( - IReadOnlyDictionary rawData + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixWithAllocationPrice value, + JsonElement? element = null ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePrice(FrozenDictionary rawData) + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration 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( + NewSubscriptionUnitWithProrationPrice value, + JsonElement? element = null ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsReplacePrice(string replacesPriceID) - : this() + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedAllocationPrice value, + JsonElement? element = null + ) { - this.ReplacesPriceID = replacesPriceID; + this.Value = value; + this._element = element; } -} -class SubscriptionSchedulePlanChangeParamsReplacePriceFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsReplacePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsReplacePrice.FromRawUnchecked(rawData); -} + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionBulkWithProrationPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } -/// -/// New subscription price request body params. -/// -[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter))] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePrice : ModelBase -{ - public object? Value { get; } = null; + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedWithProratedMinimumPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - JsonElement? _element = null; + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionGroupedWithMeteredMinimumPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public JsonElement Json + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds 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( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value, + JsonElement? element = null + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.Currency, - newSubscriptionTiered: (x) => x.Currency, - newSubscriptionBulk: (x) => x.Currency, - bulkWithFilters: (x) => x.Currency, - newSubscriptionPackage: (x) => x.Currency, - newSubscriptionMatrix: (x) => x.Currency, - newSubscriptionThresholdTotalAmount: (x) => x.Currency, - newSubscriptionTieredPackage: (x) => x.Currency, - newSubscriptionTieredWithMinimum: (x) => x.Currency, - newSubscriptionGroupedTiered: (x) => x.Currency, - newSubscriptionTieredPackageWithMinimum: (x) => x.Currency, - newSubscriptionPackageWithAllocation: (x) => x.Currency, - newSubscriptionUnitWithPercent: (x) => x.Currency, - newSubscriptionMatrixWithAllocation: (x) => x.Currency, - tieredWithProration: (x) => x.Currency, - newSubscriptionUnitWithProration: (x) => x.Currency, - newSubscriptionGroupedAllocation: (x) => x.Currency, - newSubscriptionBulkWithProration: (x) => x.Currency, - newSubscriptionGroupedWithProratedMinimum: (x) => x.Currency, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.Currency, - groupedWithMinMaxThresholds: (x) => x.Currency, - newSubscriptionMatrixWithDisplayName: (x) => x.Currency, - newSubscriptionGroupedTieredPackage: (x) => x.Currency, - newSubscriptionMaxGroupTieredPackage: (x) => x.Currency, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Currency, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Currency, - newSubscriptionCumulativeGroupedBulk: (x) => x.Currency, - cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, - newSubscriptionMinimumComposite: (x) => x.Currency, - percent: (x) => x.Currency, - eventOutput: (x) => x.Currency - ); - } + this.Value = value; + this._element = element; } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + 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 + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value, + JsonElement? element = null + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.ExternalPriceID, - newSubscriptionTiered: (x) => x.ExternalPriceID, - newSubscriptionBulk: (x) => x.ExternalPriceID, - bulkWithFilters: (x) => x.ExternalPriceID, - newSubscriptionPackage: (x) => x.ExternalPriceID, - newSubscriptionMatrix: (x) => x.ExternalPriceID, - newSubscriptionThresholdTotalAmount: (x) => x.ExternalPriceID, - newSubscriptionTieredPackage: (x) => x.ExternalPriceID, - newSubscriptionTieredWithMinimum: (x) => x.ExternalPriceID, - newSubscriptionGroupedTiered: (x) => x.ExternalPriceID, - newSubscriptionTieredPackageWithMinimum: (x) => x.ExternalPriceID, - newSubscriptionPackageWithAllocation: (x) => x.ExternalPriceID, - newSubscriptionUnitWithPercent: (x) => x.ExternalPriceID, - newSubscriptionMatrixWithAllocation: (x) => x.ExternalPriceID, - tieredWithProration: (x) => x.ExternalPriceID, - newSubscriptionUnitWithProration: (x) => x.ExternalPriceID, - newSubscriptionGroupedAllocation: (x) => x.ExternalPriceID, - newSubscriptionBulkWithProration: (x) => x.ExternalPriceID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ExternalPriceID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ExternalPriceID, - groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, - newSubscriptionMatrixWithDisplayName: (x) => x.ExternalPriceID, - newSubscriptionGroupedTieredPackage: (x) => x.ExternalPriceID, - newSubscriptionMaxGroupTieredPackage: (x) => x.ExternalPriceID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, - newSubscriptionCumulativeGroupedBulk: (x) => x.ExternalPriceID, - cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, - newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, - percent: (x) => x.ExternalPriceID, - eventOutput: (x) => x.ExternalPriceID - ); - } + this.Value = value; + this._element = element; } - public double? FixedPriceQuantity + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value, + JsonElement? element = null + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.FixedPriceQuantity, - newSubscriptionTiered: (x) => x.FixedPriceQuantity, - newSubscriptionBulk: (x) => x.FixedPriceQuantity, - bulkWithFilters: (x) => x.FixedPriceQuantity, - newSubscriptionPackage: (x) => x.FixedPriceQuantity, - newSubscriptionMatrix: (x) => x.FixedPriceQuantity, - newSubscriptionThresholdTotalAmount: (x) => x.FixedPriceQuantity, - newSubscriptionTieredPackage: (x) => x.FixedPriceQuantity, - newSubscriptionTieredWithMinimum: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedTiered: (x) => x.FixedPriceQuantity, - newSubscriptionTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, - newSubscriptionPackageWithAllocation: (x) => x.FixedPriceQuantity, - newSubscriptionUnitWithPercent: (x) => x.FixedPriceQuantity, - newSubscriptionMatrixWithAllocation: (x) => x.FixedPriceQuantity, - tieredWithProration: (x) => x.FixedPriceQuantity, - newSubscriptionUnitWithProration: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedAllocation: (x) => x.FixedPriceQuantity, - newSubscriptionBulkWithProration: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, - groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, - newSubscriptionMatrixWithDisplayName: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedTieredPackage: (x) => x.FixedPriceQuantity, - newSubscriptionMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, - newSubscriptionCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, - cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, - newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, - percent: (x) => x.FixedPriceQuantity, - eventOutput: (x) => x.FixedPriceQuantity - ); - } + this.Value = value; + this._element = element; } - public string? InvoiceGroupingKey + public SubscriptionSchedulePlanChangeParamsReplacePricePrice(JsonElement element) { - get - { - return Match( - newSubscriptionUnit: (x) => x.InvoiceGroupingKey, - newSubscriptionTiered: (x) => x.InvoiceGroupingKey, - newSubscriptionBulk: (x) => x.InvoiceGroupingKey, - bulkWithFilters: (x) => x.InvoiceGroupingKey, - newSubscriptionPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionMatrix: (x) => x.InvoiceGroupingKey, - newSubscriptionThresholdTotalAmount: (x) => x.InvoiceGroupingKey, - newSubscriptionTieredPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionTieredWithMinimum: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedTiered: (x) => x.InvoiceGroupingKey, - newSubscriptionTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, - newSubscriptionPackageWithAllocation: (x) => x.InvoiceGroupingKey, - newSubscriptionUnitWithPercent: (x) => x.InvoiceGroupingKey, - newSubscriptionMatrixWithAllocation: (x) => x.InvoiceGroupingKey, - tieredWithProration: (x) => x.InvoiceGroupingKey, - newSubscriptionUnitWithProration: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedAllocation: (x) => x.InvoiceGroupingKey, - newSubscriptionBulkWithProration: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, - groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, - newSubscriptionMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedTieredPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, - newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, - cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, - newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, - percent: (x) => x.InvoiceGroupingKey, - eventOutput: (x) => x.InvoiceGroupingKey - ); - } + this._element = element; } - 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.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.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 - ); - } + value = this.Value as NewSubscriptionUnitPrice; + 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.TryPickNewSubscriptionTiered(out var value)) { + /// // `value` is of type `NewSubscriptionTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTiered( + [NotNullWhen(true)] out NewSubscriptionTieredPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionTieredPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - 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.TryPickNewSubscriptionBulk(out var value)) { + /// // `value` is of type `NewSubscriptionBulkPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionBulk([NotNullWhen(true)] out NewSubscriptionBulkPrice? value) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionBulkPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - 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.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters( + [NotNullWhen(true)] + out SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters? value ) { - this.Value = value; - this._element = element; + value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - 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.TryPickNewSubscriptionPackage(out var value)) { + /// // `value` is of type `NewSubscriptionPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionPackage( + [NotNullWhen(true)] out NewSubscriptionPackagePrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionPackagePrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - 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.TryPickNewSubscriptionMatrix(out var value)) { + /// // `value` is of type `NewSubscriptionMatrixPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionMatrix( + [NotNullWhen(true)] out NewSubscriptionMatrixPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionMatrixPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - 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.TryPickNewSubscriptionThresholdTotalAmount(out var value)) { + /// // `value` is of type `NewSubscriptionThresholdTotalAmountPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionThresholdTotalAmount( + [NotNullWhen(true)] out NewSubscriptionThresholdTotalAmountPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionThresholdTotalAmountPrice; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - 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.TryPickNewSubscriptionTieredPackage(out var value)) { + /// // `value` is of type `NewSubscriptionTieredPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTieredPackage( + [NotNullWhen(true)] out NewSubscriptionTieredPackagePrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionTieredPackagePrice; + return value != null; } - public 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.TryPickNewSubscriptionTieredWithMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTieredWithMinimum( + [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value ) { - this.Value = value; - this._element = element; + value = this.Value as NewSubscriptionTieredWithMinimumPrice; + return value != null; } - public 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.TryPickNewSubscriptionGroupedTiered(out var value)) { + /// // `value` is of type `NewSubscriptionGroupedTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionGroupedTiered( + [NotNullWhen(true)] out NewSubscriptionGroupedTieredPrice? value ) { - this.Value = value; - this._element = element; - } - - 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 NewSubscriptionGroupedTieredPrice; + return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionUnit(out var value)) { - /// // `value` is of type `NewSubscriptionUnitPrice` + /// if (instance.TryPickNewSubscriptionTieredPackageWithMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionTieredPackageWithMinimumPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUnitPrice? value) + public bool TryPickNewSubscriptionTieredPackageWithMinimum( + [NotNullWhen(true)] out NewSubscriptionTieredPackageWithMinimumPrice? value + ) { - value = this.Value as NewSubscriptionUnitPrice; + value = this.Value as NewSubscriptionTieredPackageWithMinimumPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionTiered(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPrice` + /// if (instance.TryPickNewSubscriptionPackageWithAllocation(out var value)) { + /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionTiered( - [NotNullWhen(true)] out NewSubscriptionTieredPrice? value + public bool TryPickNewSubscriptionPackageWithAllocation( + [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value ) { - value = this.Value as NewSubscriptionTieredPrice; + value = this.Value as NewSubscriptionPackageWithAllocationPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionBulk(out var value)) { - /// // `value` is of type `NewSubscriptionBulkPrice` + /// if (instance.TryPickNewSubscriptionUnitWithPercent(out var value)) { + /// // `value` is of type `NewSubscriptionUnitWithPercentPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionBulk([NotNullWhen(true)] out NewSubscriptionBulkPrice? value) + public bool TryPickNewSubscriptionUnitWithPercent( + [NotNullWhen(true)] out NewSubscriptionUnitWithPercentPrice? value + ) { - value = this.Value as NewSubscriptionBulkPrice; + value = this.Value as NewSubscriptionUnitWithPercentPrice; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters` + /// if (instance.TryPickNewSubscriptionMatrixWithAllocation(out var value)) { + /// // `value` is of type `NewSubscriptionMatrixWithAllocationPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters? value + public bool TryPickNewSubscriptionMatrixWithAllocation( + [NotNullWhen(true)] out NewSubscriptionMatrixWithAllocationPrice? value ) { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionPackage(out var value)) { - /// // `value` is of type `NewSubscriptionPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionPackage( - [NotNullWhen(true)] out NewSubscriptionPackagePrice? value - ) - { - value = this.Value as NewSubscriptionPackagePrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMatrix(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMatrix( - [NotNullWhen(true)] out NewSubscriptionMatrixPrice? value - ) - { - value = this.Value as NewSubscriptionMatrixPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewSubscriptionThresholdTotalAmountPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionThresholdTotalAmount( - [NotNullWhen(true)] out NewSubscriptionThresholdTotalAmountPrice? value - ) - { - value = this.Value as NewSubscriptionThresholdTotalAmountPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionTieredPackage( - [NotNullWhen(true)] out NewSubscriptionTieredPackagePrice? value - ) - { - value = this.Value as NewSubscriptionTieredPackagePrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionTieredWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionTieredWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value - ) - { - value = this.Value as NewSubscriptionTieredWithMinimumPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionGroupedTiered(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedTieredPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedTiered( - [NotNullWhen(true)] out NewSubscriptionGroupedTieredPrice? value - ) - { - value = this.Value as NewSubscriptionGroupedTieredPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackageWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionTieredPackageWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredPackageWithMinimumPrice? value - ) - { - value = this.Value as NewSubscriptionTieredPackageWithMinimumPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionPackageWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionPackageWithAllocation( - [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value - ) - { - value = this.Value as NewSubscriptionPackageWithAllocationPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionUnitWithPercent(out var value)) { - /// // `value` is of type `NewSubscriptionUnitWithPercentPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionUnitWithPercent( - [NotNullWhen(true)] out NewSubscriptionUnitWithPercentPrice? value - ) - { - value = this.Value as NewSubscriptionUnitWithPercentPrice; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMatrixWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMatrixWithAllocation( - [NotNullWhen(true)] out NewSubscriptionMatrixWithAllocationPrice? value - ) - { - value = this.Value as NewSubscriptionMatrixWithAllocationPrice; + value = this.Value as NewSubscriptionMatrixWithAllocationPrice; return value != null; } @@ -12783,7 +12237,7 @@ public bool TryPickNewSubscriptionMatrixWithAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -12808,7 +12262,7 @@ out SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -12831,7 +12285,7 @@ public bool TryPickNewSubscriptionUnitWithProration( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -12854,7 +12308,7 @@ public bool TryPickNewSubscriptionGroupedAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -12877,7 +12331,7 @@ public bool TryPickNewSubscriptionBulkWithProration( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -12900,7 +12354,7 @@ public bool TryPickNewSubscriptionGroupedWithProratedMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -12923,7 +12377,7 @@ public bool TryPickNewSubscriptionGroupedWithMeteredMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -12949,7 +12403,7 @@ out SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresh /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -12972,7 +12426,7 @@ public bool TryPickNewSubscriptionMatrixWithDisplayName( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -12995,7 +12449,7 @@ public bool TryPickNewSubscriptionGroupedTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -13018,7 +12472,7 @@ public bool TryPickNewSubscriptionMaxGroupTieredPackage( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -13041,7 +12495,7 @@ public bool TryPickNewSubscriptionScalableMatrixWithUnitPricing( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -13064,7 +12518,7 @@ public bool TryPickNewSubscriptionScalableMatrixWithTieredPricing( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -13087,7 +12541,7 @@ public bool TryPickNewSubscriptionCumulativeGroupedBulk( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -13109,34 +12563,11 @@ out SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAlloca return value != null; } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] out SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum? value - ) - { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum; - return value != null; - } - /// /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -13159,7 +12590,7 @@ public bool TryPickNewSubscriptionMinimumComposite( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -13182,7 +12613,7 @@ public bool TryPickPercent( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -13205,7 +12636,7 @@ out SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput? value /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -13216,38 +12647,37 @@ out SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput? 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) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value) => {...} + /// (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) => {...} /// ); /// /// @@ -13281,7 +12711,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 @@ -13373,9 +12802,6 @@ public void Switch( case SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value: cumulativeGroupedAllocation(value); break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value: - minimum(value); - break; case NewSubscriptionMinimumCompositePrice value: newSubscriptionMinimumComposite(value); break; @@ -13396,7 +12822,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -13407,38 +12833,37 @@ public void Switch( /// /// /// 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) => {...} + /// (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) => {...} /// ); /// /// @@ -13520,7 +12945,6 @@ public T Match( SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, T > cumulativeGroupedAllocation, - System::Func minimum, System::Func newSubscriptionMinimumComposite, System::Func percent, System::Func< @@ -13582,7 +13006,6 @@ public T Match( ), SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation(value), - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value => minimum(value), NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value => percent(value), SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value => eventOutput( @@ -13706,10 +13129,6 @@ public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePrice SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value - ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( NewSubscriptionMinimumCompositePrice value ) => new(value); @@ -13778,17 +13197,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(SubscriptionSchedulePlanChangeParamsReplacePricePrice? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SubscriptionSchedulePlanChangeParamsReplacePricePrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -13796,7 +13214,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 + { + NewSubscriptionUnitPrice _ => 0, + NewSubscriptionTieredPrice _ => 1, + NewSubscriptionBulkPrice _ => 2, + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters _ => 3, + NewSubscriptionPackagePrice _ => 4, + NewSubscriptionMatrixPrice _ => 5, + NewSubscriptionThresholdTotalAmountPrice _ => 6, + NewSubscriptionTieredPackagePrice _ => 7, + NewSubscriptionTieredWithMinimumPrice _ => 8, + NewSubscriptionGroupedTieredPrice _ => 9, + NewSubscriptionTieredPackageWithMinimumPrice _ => 10, + NewSubscriptionPackageWithAllocationPrice _ => 11, + NewSubscriptionUnitWithPercentPrice _ => 12, + NewSubscriptionMatrixWithAllocationPrice _ => 13, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration _ => 14, + NewSubscriptionUnitWithProrationPrice _ => 15, + NewSubscriptionGroupedAllocationPrice _ => 16, + NewSubscriptionBulkWithProrationPrice _ => 17, + NewSubscriptionGroupedWithProratedMinimumPrice _ => 18, + NewSubscriptionGroupedWithMeteredMinimumPrice _ => 19, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds _ => + 20, + NewSubscriptionMatrixWithDisplayNamePrice _ => 21, + NewSubscriptionGroupedTieredPackagePrice _ => 22, + NewSubscriptionMaxGroupTieredPackagePrice _ => 23, + NewSubscriptionScalableMatrixWithUnitPricingPrice _ => 24, + NewSubscriptionScalableMatrixWithTieredPricingPrice _ => 25, + NewSubscriptionCumulativeGroupedBulkPrice _ => 26, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation _ => + 27, + NewSubscriptionMinimumCompositePrice _ => 28, + SubscriptionSchedulePlanChangeParamsReplacePricePricePercent _ => 29, + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput _ => 30, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter @@ -13831,12 +13293,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -13853,12 +13313,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -13875,12 +13333,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -13898,12 +13354,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -13920,12 +13374,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -13942,12 +13394,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -13965,12 +13415,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -13988,12 +13436,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14011,12 +13457,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14034,12 +13478,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14057,12 +13499,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14080,12 +13520,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14103,12 +13541,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14126,12 +13562,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14149,12 +13583,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14172,12 +13604,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14195,12 +13625,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14218,12 +13646,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14241,12 +13667,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14264,12 +13688,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14287,12 +13709,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -14301,1280 +13721,208 @@ JsonSerializerOptions options } 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 - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); - } - init { this._rawData.Set("unit_amount", value); } - } - - /// - /// The lower bound for this tier - /// - public string? TierLowerBound - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("tier_lower_bound"); - } - init { this._rawData.Set("tier_lower_bound", value); } - } - - /// - public override void Validate() - { - _ = this.UnitAmount; - _ = this.TierLowerBound; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() - { } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - ) - : base( - subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier - ) { } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - IReadOnlyDictionary rawData - ) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - FrozenDictionary rawData - ) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( - string unitAmount - ) - : this() - { - this.UnitAmount = unitAmount; - } -} - -class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw - : IFromRawJson -{ - /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked( - rawData - ); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceConverter) -)] -public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceConverter - : JsonConverter -{ - public override SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, - "semi_annual" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.SemiAnnual, - "monthly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Monthly, - "quarterly" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Quarterly, - "one_time" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.OneTime, - "custom" => - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual => - "annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.SemiAnnual => - "semi_annual", - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Monthly => - "monthly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Quarterly => - "quarterly", - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.OneTime => - "one_time", - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Custom => - "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } -} - -[JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfigConverter) -)] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig - : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( - JsonElement element - ) - { - this._element = element; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) - { - value = this.Value as SharedUnitConversionRateConfig; - return value != null; - } - - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) - { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) - { - switch (this.Value) - { - case SharedUnitConversionRateConfig value: - unit(value); - break; - case SharedTieredConversionRateConfig value: - tiered(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" - ); - } - } - - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) - { - return this.Value switch - { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" - ), - }; - } + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public override int GetHashCode() - { - return 0; - } + return new(element); + } + case "cumulative_grouped_bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // 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(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } 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(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -15583,38 +13931,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 +13984,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence > >("cadence"); } @@ -15669,21 +14030,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 +14089,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 +14185,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +14236,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 +14260,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 +14297,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15943,147 +14306,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 +14501,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( FrozenDictionary rawData ) { @@ -16100,92 +14509,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 +14597,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( FrozenDictionary rawData ) { @@ -16202,31 +14605,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 +14730,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16253,7 +14739,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationC this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16262,7 +14748,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationC this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( JsonElement element ) { @@ -16273,7 +14759,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -16294,7 +14780,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -16314,7 +14800,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -16325,8 +14811,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16346,7 +14832,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" ); } } @@ -16355,7 +14841,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -16366,8 +14852,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16382,16 +14868,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 +14896,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 +14915,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 @@ -16464,12 +14963,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -16486,12 +14983,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -16500,7 +14995,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( element ); } @@ -16509,7 +15004,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value, JsonSerializerOptions options ) { @@ -16519,11 +15014,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration : JsonModel { /// @@ -16531,7 +15026,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePrice /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > Cadence { get @@ -16540,26 +15035,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 +15081,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 +15155,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 +15251,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +15303,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 +15326,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 +15363,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16860,14 +15372,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration.FromRawUnchecked( rawData ); } @@ -16876,9 +15388,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 +15400,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 +15412,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 +15439,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 +15461,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 +15629,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -17049,8 +15637,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17058,22 +15646,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 +15679,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17100,7 +15688,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThr this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17109,7 +15697,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThr this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( JsonElement element ) { @@ -17120,7 +15708,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -17141,7 +15729,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -17161,7 +15749,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -17172,8 +15760,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17193,7 +15781,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" ); } } @@ -17202,7 +15790,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -17213,8 +15801,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17229,16 +15817,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 +15845,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 +15864,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 @@ -17311,12 +15912,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -17333,12 +15932,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -17347,7 +15944,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( element ); } @@ -17356,7 +15953,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -17366,11 +15963,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds : JsonModel { /// @@ -17378,7 +15975,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePrice /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > Cadence { get @@ -17387,7 +15984,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >("cadence"); } @@ -17395,18 +15992,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 +16104,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 +16200,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +16252,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 +16275,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 +16312,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17707,14 +16321,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( rawData ); } @@ -17723,9 +16337,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 +16349,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 +16361,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 +16381,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -17775,17 +16389,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 +16411,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 +16505,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -17896,8 +16513,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17905,22 +16522,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 +16555,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17947,7 +16564,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAll this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17956,7 +16573,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAll this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( JsonElement element ) { @@ -17967,7 +16584,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -17988,7 +16605,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -18008,7 +16625,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -18019,8 +16636,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18040,7 +16657,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" ); } } @@ -18049,7 +16666,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -18060,8 +16677,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18076,16 +16693,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 +16721,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 +16740,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 @@ -18158,12 +16788,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -18180,12 +16808,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -18194,7 +16820,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -18203,7 +16829,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -18213,56 +16839,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 +16980,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 +17076,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +17128,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 +17151,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 +17188,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -18545,22 +17197,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 +17225,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 +17236,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 +17265,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 +17287,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 +17381,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( FrozenDictionary rawData ) { @@ -18703,40 +17389,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 +17431,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -18763,7 +17440,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRat this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -18772,7 +17449,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRat this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( JsonElement element ) { @@ -18783,7 +17460,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -18804,7 +17481,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -18824,7 +17501,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -18835,8 +17512,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18856,7 +17533,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" ); } } @@ -18865,7 +17542,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -18876,8 +17553,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18892,16 +17569,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 +17597,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 +17616,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 @@ -18974,12 +17664,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -18996,12 +17684,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -19010,7 +17696,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -19019,7 +17705,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -19262,6 +17948,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +18018,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -19328,10 +18028,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 +18178,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 @@ -19575,7 +18281,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -19596,7 +18302,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -19616,7 +18322,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -19627,8 +18333,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19657,7 +18363,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -19668,8 +18374,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19720,10 +18426,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 +18437,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 @@ -19766,12 +18485,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -19788,12 +18505,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -20058,6 +18773,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +18848,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -20129,10 +18858,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 +19041,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 @@ -20412,7 +19147,7 @@ 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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -20433,7 +19168,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -20453,7 +19188,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -20464,8 +19199,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -20494,7 +19229,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -20505,8 +19240,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -20557,10 +19292,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 +19303,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 @@ -20603,12 +19351,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -20625,12 +19371,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } 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..936777b81 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, @@ -79,27 +86,61 @@ IReadOnlyDictionary rawBodyData SubscriptionTriggerPhaseParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionTriggerPhaseParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + subscriptionID + ); + } + + 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) @@ -130,4 +171,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Subscriptions/SubscriptionUnscheduleCancellationParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUnscheduleCancellationParams.cs index 0efc26fb4..2ec24f568 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, @@ -42,26 +49,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] SubscriptionUnscheduleCancellationParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionUnscheduleCancellationParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + subscriptionID ); } + 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 +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/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.cs index 3e356fe6b..67b78ba67 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, @@ -66,29 +73,63 @@ IReadOnlyDictionary rawBodyData SubscriptionUnscheduleFixedFeeQuantityUpdatesParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionUnscheduleFixedFeeQuantityUpdatesParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + subscriptionID ); } + 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 +161,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUnschedulePendingPlanChangesParams.cs index 7f50496aa..1e57a4a7d 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, @@ -39,24 +46,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] SubscriptionUnschedulePendingPlanChangesParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionUnschedulePendingPlanChangesParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + subscriptionID + ); + } + + 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) @@ -81,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/Subscriptions/SubscriptionUpdateFixedFeeQuantityParams.cs b/src/Orb/Models/Subscriptions/SubscriptionUpdateFixedFeeQuantityParams.cs index afd9dab9f..9218d0169 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, @@ -141,27 +148,61 @@ IReadOnlyDictionary rawBodyData SubscriptionUpdateFixedFeeQuantityParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionUpdateFixedFeeQuantityParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + subscriptionID + ); + } + + 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) @@ -192,6 +233,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..7533f653f 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, @@ -132,27 +139,61 @@ IReadOnlyDictionary rawBodyData SubscriptionUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + subscriptionID + ); + } + + 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) @@ -183,4 +224,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..3af70a5f0 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, @@ -105,27 +112,61 @@ IReadOnlyDictionary rawBodyData SubscriptionUpdateTrialParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionUpdateTrialParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + subscriptionID + ); + } + + 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) @@ -156,6 +197,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -201,7 +247,7 @@ public TrialEndDate(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -220,14 +266,14 @@ public bool TryPickDateTimeOffset([NotNullWhen(true)] out System::DateTimeOffset /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type with a TRaw of string and a TEnum of UnionMember1>. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickUnionMember1(out var value)) { - /// // `value` is of type `ApiEnum` + /// // `value` is of type `ApiEnum<string, UnionMember1>` /// Console.WriteLine(value); /// } /// @@ -242,7 +288,7 @@ public bool TryPickUnionMember1([NotNullWhen(true)] out ApiEnum /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -253,8 +299,8 @@ public bool TryPickUnionMember1([NotNullWhen(true)] out ApiEnum /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, UnionMember1> value) => {...} /// ); /// /// @@ -281,7 +327,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -292,8 +338,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, UnionMember1> value) => {...} /// ); /// /// @@ -338,10 +384,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 +395,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 +439,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..ba39627dc 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionUsage.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionUsage.cs @@ -49,7 +49,7 @@ public SubscriptionUsage(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. + /// Consider using or if you need to handle every variant. /// /// /// @@ -70,7 +70,7 @@ public bool TryPickUngrouped([NotNullWhen(true)] out UngroupedSubscriptionUsage? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -90,7 +90,7 @@ public bool TryPickGrouped([NotNullWhen(true)] out GroupedSubscriptionUsage? val /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -101,8 +101,8 @@ public bool TryPickGrouped([NotNullWhen(true)] out GroupedSubscriptionUsage? val /// /// /// instance.Switch( - /// (UngroupedSubscriptionUsage value) => {...}, - /// (GroupedSubscriptionUsage value) => {...} + /// (UngroupedSubscriptionUsage value) => {...}, + /// (GroupedSubscriptionUsage value) => {...} /// ); /// /// @@ -131,7 +131,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -142,8 +142,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (UngroupedSubscriptionUsage value) => {...}, - /// (GroupedSubscriptionUsage value) => {...} + /// (UngroupedSubscriptionUsage value) => {...}, + /// (GroupedSubscriptionUsage value) => {...} /// ); /// /// @@ -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..ad8779052 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, @@ -44,7 +51,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static TopLevelPingParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -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..418f3fd81 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 { @@ -89,7 +93,7 @@ public interface IExternalPlanIDServiceWithRawResponse IExternalPlanIDServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /plans/external_plan_id/{external_plan_id}/versions`, but is otherwise the + /// Returns a raw HTTP response for post /plans/external_plan_id/{external_plan_id}/versions, but is otherwise the /// same as . /// Task> CreatePlanVersion( @@ -105,7 +109,7 @@ Task> CreatePlanVersion( ); /// - /// Returns a raw HTTP response for `get /plans/external_plan_id/{external_plan_id}/versions/{version}`, but is otherwise the + /// Returns a raw HTTP response for get /plans/external_plan_id/{external_plan_id}/versions/{version}, but is otherwise the /// same as . /// Task> FetchPlanVersion( @@ -121,7 +125,7 @@ Task> FetchPlanVersion( ); /// - /// Returns a raw HTTP response for `post /plans/external_plan_id/{external_plan_id}/set_default_version`, but is otherwise the + /// Returns a raw HTTP response for post /plans/external_plan_id/{external_plan_id}/set_default_version, but is otherwise the /// same as . /// Task> SetDefaultPlanVersion( diff --git a/src/Orb/Services/Coupons/ISubscriptionService.cs b/src/Orb/Services/Coupons/ISubscriptionService.cs index cbf3ddb5b..16c660cab 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,21 +22,19 @@ 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 - /// coupon as a [paginated](/api-reference/pagination) list, ordered starting - /// from the most recently created subscription. For a full discussion of the + /// coupon 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). /// Task List( @@ -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 . + /// Returns a raw HTTP response for get /coupons/{coupon_id}/subscriptions, but is otherwise the + /// 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..3467ea277 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 { @@ -32,69 +35,70 @@ public interface ILedgerService /// balance. This [paginated endpoint](/api-reference/pagination) lists these /// entries, starting from the most recent ledger entry. /// - /// More details on using Orb's real-time credit feature are [here](/product-catalog/prepurchase). + /// More details on using Orb's real-time credit feature are + /// [here](/product-catalog/prepurchase). /// - /// There are four major types of modifications to credit balance, detailed below. + /// There are four major types of modifications to credit balance, detailed + /// below. /// - /// ## Increment Credits (which optionally expire on a future date) can - /// be added via the API ([Add Ledger Entry](create-ledger-entry)). The ledger - /// entry for such an action will always contain the total eligible starting and - /// ending balance for the customer at the time the entry was added to the ledger. + /// ## Increment Credits (which optionally expire on a future date) can be + /// added via the API ([Add Ledger Entry](create-ledger-entry)). The ledger entry + /// for such an action will always contain the total eligible starting and ending + /// balance for the customer at the time the entry was added to the ledger. /// - /// ## Decrement Deductions can occur as a result of an API call to create - /// a ledger entry (see [Add Ledger Entry](create-ledger-entry)), or automatically - /// as a result of incurring usage. Both ledger entries present the `decrement` - /// entry type. + /// ## Decrement Deductions can occur as a result of an API call to create a + /// ledger entry (see [Add Ledger Entry](create-ledger-entry)), or automatically as + /// a result of incurring usage. Both ledger entries present the `decrement` entry + /// type. /// /// 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. + /// 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. + /// 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 appropriately. As an example, if trial credits with an expiration - /// date of 2 weeks from now are present for a customer, they will be used before - /// any deductions take place from a non-expiring credit block. + /// *soonest expiring credit block* first in order to ensure that all credits are + /// utilized appropriately. As an example, if trial credits with an expiration date + /// of 2 weeks from now are present for a customer, they will be used before any + /// deductions take place from a non-expiring credit block. /// /// If there are multiple blocks with the same expiration date, Orb will - /// deduct from the block with the *lower cost basis* first (e.g. trial credits - /// with a \$0 cost basis before paid credits with a \$5.00 cost basis). + /// deduct from the block with the *lower cost basis* first (e.g. trial credits with + /// a \$0 cost basis before paid credits with a \$5.00 cost basis). /// /// It's also possible for a single usage event's deduction to _span_ credit - /// blocks. In this case, Orb will deduct from the next block, ending at the - /// credit block which consists of unexpiring credits. Each of these deductions - /// will lead to a _separate_ ledger entry, one per credit block that is deducted - /// from. By default, the customer's total credit balance in Orb can be negative - /// as a result of a decrement. - /// - /// ## Expiration change The expiry of credits can be changed as a result - /// of the API (See [Add Ledger Entry](create-ledger-entry)). This will create - /// a ledger entry that specifies the balance as well as the initial and target - /// expiry dates. - /// - /// Note that for this entry type, `starting_balance` will equal `ending_balance`, - /// and the `amount` represents the balance transferred. The credit block linked - /// to the ledger entry is the source credit block from which there was an expiration change. - /// - /// ## Credits expiry When a set of credits expire on pre-set expiration - /// date, the customer's balance automatically reflects this change and adds - /// an entry to the ledger indicating this event. Note that credit expiry should - /// always happen close to a date boundary in the customer's timezone. - /// - /// ## Void initiated Credit blocks can be voided via the API. The `amount` - /// on this entry corresponds to the number of credits that were remaining in - /// the block at time of void. `void_reason` will be populated if the void is - /// created with a reason. - /// - /// ## Void When a set of credits is voided, the customer's balance automatically - /// reflects this change and adds an entry to the ledger indicating this event. - /// - /// ## 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 + /// blocks. In this case, Orb will deduct from the next block, ending at the credit + /// block which consists of unexpiring credits. Each of these deductions will lead + /// to a _separate_ ledger entry, one per credit block that is deducted from. By + /// default, the customer's total credit balance in Orb can be negative as a result + /// of a decrement. + /// + /// ## Expiration change The expiry of credits can be changed as a result of + /// the API (See [Add Ledger Entry](create-ledger-entry)). This will create a ledger + /// entry that specifies the balance as well as the initial and target expiry dates. + /// + /// Note that for this entry type, `starting_balance` will equal + /// `ending_balance`, and the `amount` represents the balance transferred. The + /// credit block linked to the ledger entry is the source credit block from which + /// there was an expiration change. + /// + /// ## Credits expiry When a set of credits expire on pre-set expiration date, + /// the customer's balance automatically reflects this change and adds an entry to + /// the ledger indicating this event. Note that credit expiry should always happen + /// close to a date boundary in the customer's timezone. + /// + /// ## Void initiated Credit blocks can be voided via the API. The `amount` on + /// this entry corresponds to the number of credits that were remaining in the block + /// at time of void. `void_reason` will be populated if the void is created with a + /// reason. + /// + /// ## Void When a set of credits is voided, the customer's balance + /// automatically reflects this change and adds an entry to the ledger indicating + /// this event. + /// + /// ## 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. /// Task List( @@ -111,75 +115,83 @@ Task List( /// /// This endpoint allows you to create a new ledger entry for a specified customer's - /// balance. This can be used to increment balance, deduct credits, and change - /// the expiry date of existing credits. - /// - /// ## Effects of adding a ledger entry 1. After calling this endpoint, - /// [Fetch Credit Balance](fetch-customer-credits) will return a credit block - /// that represents the changes (i.e. balance changes or transfers). 2. A ledger - /// entry will be added to the credits ledger for this customer, and therefore - /// returned in the [View Credits Ledger](fetch-customer-credits-ledger) response - /// as well as serialized in the response to this request. In the case of deductions - /// without a specified block, multiple ledger entries may be created if the deduction - /// spans credit blocks. 3. If `invoice_settings` is specified, an invoice - /// will be created that reflects the cost of the credits (based on `amount` - /// and `per_unit_cost_basis`). - /// - /// ## Adding credits Adding credits is done by creating an entry of - /// type `increment`. This requires the caller to specify a number of credits - /// as well as an optional expiry date in `YYYY-MM-DD` format. Orb also recommends + /// balance. This can be used to increment balance, deduct credits, and change the + /// expiry date of existing credits. + /// + /// ## Effects of adding a ledger entry 1. After calling this endpoint, [Fetch + /// Credit Balance](fetch-customer-credits) will return a credit block that + /// represents the changes (i.e. balance changes or transfers). 2. A ledger entry + /// will be added to the credits ledger for this customer, and therefore returned in + /// the [View Credits Ledger](fetch-customer-credits-ledger) response as well as + /// serialized in the response to this request. In the case of deductions without + /// a specified block, multiple ledger entries may be created if the deduction spans + /// credit blocks. 3. If `invoice_settings` is specified, an invoice will be + /// created that reflects the cost of the credits (based on `amount` and + /// `per_unit_cost_basis`). + /// + /// ## Adding credits Adding credits is done by creating an entry of type + /// `increment`. This requires the caller to specify a number of credits as well + /// as an optional expiry date in `YYYY-MM-DD` format. Orb also recommends /// specifying a description to assist with auditing. When adding credits, the - /// caller can also specify a cost basis per-credit, to indicate how much in - /// USD a customer paid for a single credit in a block. This can later be used - /// for revenue recognition. + /// caller can also specify a cost basis per-credit, to indicate how much in USD a + /// customer paid for a single credit in a block. This can later be used for revenue + /// recognition. /// /// The following snippet illustrates a sample request body to increment /// credits which will expire in January of 2022. /// /// ```json { "entry_type": "increment", "amount": 100, "expiry_date": - /// "2022-12-28", "per_unit_cost_basis": "0.20", "description": "Purchased - /// 100 credits" } ``` + /// "2022-12-28", "per_unit_cost_basis": "0.20", "description": "Purchased 100 + /// credits" } ``` /// /// Note that by default, Orb will always first increment any _negative_ /// balance in existing blocks before adding the remaining amount to the desired /// credit block. /// /// ### Invoicing for credits By default, Orb manipulates the credit ledger - /// but does not charge for credits. However, if you pass `invoice_settings` - /// 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. - /// - /// ## Deducting Credits Orb allows you to deduct credits from a customer - /// by creating an entry of type `decrement`. Orb matches the algorithm for automatic - /// deductions for determining which credit blocks to decrement from. In the - /// case that the deduction leads to multiple ledger entries, the response from - /// this endpoint will be the final deduction. Orb also optionally allows specifying - /// a description to assist with auditing. - /// - /// The following snippet illustrates a sample request body to decrement credits. + /// but does not charge for credits. However, if you pass `invoice_settings` in the + /// body of this request, Orb will also generate a one-off invoice for the customer + /// for the credits pre-purchase. Note that you _must_ provide the + /// `per_unit_cost_basis`, since the total charges on the invoice are calculated by + /// multiplying the cost basis with the number of credit units added. If 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 + /// deductions for determining which credit blocks to decrement from. In the case + /// that the deduction leads to multiple ledger entries, the response from this + /// endpoint will be the final deduction. Orb also optionally allows specifying a + /// description to assist with auditing. + /// + /// The following snippet illustrates a sample request body to decrement + /// credits. /// /// ```json { "entry_type": "decrement", "amount": 20, "description": /// "Removing excess credits" } ``` /// /// ## Changing credits expiry If you'd like to change when existing credits - /// expire, you should create a ledger entry of type `expiration_change`. For - /// this entry, the required parameter `expiry_date` identifies the _originating_ - /// block, and the required parameter `target_expiry_date` identifies when the - /// transferred credits should now expire. A new credit block will be created - /// with expiry date `target_expiry_date`, with the same cost basis data as the - /// original credit block, if present. + /// expire, you should create a ledger entry of type `expiration_change`. For this + /// entry, the required parameter `expiry_date` identifies the _originating_ block, + /// and the required parameter `target_expiry_date` identifies when the transferred + /// credits should now expire. A new credit block will be created with expiry date + /// `target_expiry_date`, with the same cost basis data as the original credit + /// block, if present. /// - /// Note that the balance of the block with the given `expiry_date` must - /// be at least equal to the desired transfer amount determined by the `amount` parameter. + /// Note that the balance of the block with the given `expiry_date` must be at + /// least equal to the desired transfer amount determined by the `amount` parameter. /// /// The following snippet illustrates a sample request body to extend the /// expiration date of credits by one year: /// - /// ```json { "entry_type": "expiration_change", "amount": 10, "expiry_date": - /// "2022-12-28", "block_id": "UiUhFWeLHPrBY4Ad", "target_expiry_date": "2023-12-28", - /// "description": "Extending credit validity" } ``` + /// ```json { "entry_type": "expiration_change", "amount": 10, + /// "expiry_date": "2022-12-28", "block_id": "UiUhFWeLHPrBY4Ad", + /// "target_expiry_date": "2023-12-28", "description": "Extending credit validity" + /// } ``` /// /// ## Voiding credits /// @@ -190,10 +202,10 @@ Task List( /// /// ## Amendment /// - /// If you'd like to undo a decrement on a credit block, create a ledger - /// entry 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. + /// If you'd like to undo a decrement on a credit block, create a ledger entry + /// 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. /// Task CreateEntry( LedgerCreateEntryParams parameters, @@ -209,75 +221,83 @@ Task CreateEntry( /// /// This endpoint allows you to create a new ledger entry for a specified customer's - /// balance. This can be used to increment balance, deduct credits, and change - /// the expiry date of existing credits. - /// - /// ## Effects of adding a ledger entry 1. After calling this endpoint, - /// [Fetch Credit Balance](fetch-customer-credits) will return a credit block - /// that represents the changes (i.e. balance changes or transfers). 2. A ledger - /// entry will be added to the credits ledger for this customer, and therefore - /// returned in the [View Credits Ledger](fetch-customer-credits-ledger) response - /// as well as serialized in the response to this request. In the case of deductions - /// without a specified block, multiple ledger entries may be created if the deduction - /// spans credit blocks. 3. If `invoice_settings` is specified, an invoice - /// will be created that reflects the cost of the credits (based on `amount` - /// and `per_unit_cost_basis`). - /// - /// ## Adding credits Adding credits is done by creating an entry of - /// type `increment`. This requires the caller to specify a number of credits - /// as well as an optional expiry date in `YYYY-MM-DD` format. Orb also recommends + /// balance. This can be used to increment balance, deduct credits, and change the + /// expiry date of existing credits. + /// + /// ## Effects of adding a ledger entry 1. After calling this endpoint, [Fetch + /// Credit Balance](fetch-customer-credits) will return a credit block that + /// represents the changes (i.e. balance changes or transfers). 2. A ledger entry + /// will be added to the credits ledger for this customer, and therefore returned in + /// the [View Credits Ledger](fetch-customer-credits-ledger) response as well as + /// serialized in the response to this request. In the case of deductions without + /// a specified block, multiple ledger entries may be created if the deduction spans + /// credit blocks. 3. If `invoice_settings` is specified, an invoice will be + /// created that reflects the cost of the credits (based on `amount` and + /// `per_unit_cost_basis`). + /// + /// ## Adding credits Adding credits is done by creating an entry of type + /// `increment`. This requires the caller to specify a number of credits as well + /// as an optional expiry date in `YYYY-MM-DD` format. Orb also recommends /// specifying a description to assist with auditing. When adding credits, the - /// caller can also specify a cost basis per-credit, to indicate how much in - /// USD a customer paid for a single credit in a block. This can later be used - /// for revenue recognition. + /// caller can also specify a cost basis per-credit, to indicate how much in USD a + /// customer paid for a single credit in a block. This can later be used for revenue + /// recognition. /// /// The following snippet illustrates a sample request body to increment /// credits which will expire in January of 2022. /// /// ```json { "entry_type": "increment", "amount": 100, "expiry_date": - /// "2022-12-28", "per_unit_cost_basis": "0.20", "description": "Purchased - /// 100 credits" } ``` + /// "2022-12-28", "per_unit_cost_basis": "0.20", "description": "Purchased 100 + /// credits" } ``` /// /// Note that by default, Orb will always first increment any _negative_ /// balance in existing blocks before adding the remaining amount to the desired /// credit block. /// /// ### Invoicing for credits By default, Orb manipulates the credit ledger - /// but does not charge for credits. However, if you pass `invoice_settings` - /// 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. - /// - /// ## Deducting Credits Orb allows you to deduct credits from a customer - /// by creating an entry of type `decrement`. Orb matches the algorithm for automatic - /// deductions for determining which credit blocks to decrement from. In the - /// case that the deduction leads to multiple ledger entries, the response from - /// this endpoint will be the final deduction. Orb also optionally allows specifying - /// a description to assist with auditing. - /// - /// The following snippet illustrates a sample request body to decrement credits. + /// but does not charge for credits. However, if you pass `invoice_settings` in the + /// body of this request, Orb will also generate a one-off invoice for the customer + /// for the credits pre-purchase. Note that you _must_ provide the + /// `per_unit_cost_basis`, since the total charges on the invoice are calculated by + /// multiplying the cost basis with the number of credit units added. If 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 + /// deductions for determining which credit blocks to decrement from. In the case + /// that the deduction leads to multiple ledger entries, the response from this + /// endpoint will be the final deduction. Orb also optionally allows specifying a + /// description to assist with auditing. + /// + /// The following snippet illustrates a sample request body to decrement + /// credits. /// /// ```json { "entry_type": "decrement", "amount": 20, "description": /// "Removing excess credits" } ``` /// /// ## Changing credits expiry If you'd like to change when existing credits - /// expire, you should create a ledger entry of type `expiration_change`. For - /// this entry, the required parameter `expiry_date` identifies the _originating_ - /// block, and the required parameter `target_expiry_date` identifies when the - /// transferred credits should now expire. A new credit block will be created - /// with expiry date `target_expiry_date`, with the same cost basis data as the - /// original credit block, if present. + /// expire, you should create a ledger entry of type `expiration_change`. For this + /// entry, the required parameter `expiry_date` identifies the _originating_ block, + /// and the required parameter `target_expiry_date` identifies when the transferred + /// credits should now expire. A new credit block will be created with expiry date + /// `target_expiry_date`, with the same cost basis data as the original credit + /// block, if present. /// - /// Note that the balance of the block with the given `expiry_date` must - /// be at least equal to the desired transfer amount determined by the `amount` parameter. + /// Note that the balance of the block with the given `expiry_date` must be at + /// least equal to the desired transfer amount determined by the `amount` parameter. /// /// The following snippet illustrates a sample request body to extend the /// expiration date of credits by one year: /// - /// ```json { "entry_type": "expiration_change", "amount": 10, "expiry_date": - /// "2022-12-28", "block_id": "UiUhFWeLHPrBY4Ad", "target_expiry_date": "2023-12-28", - /// "description": "Extending credit validity" } ``` + /// ```json { "entry_type": "expiration_change", "amount": 10, + /// "expiry_date": "2022-12-28", "block_id": "UiUhFWeLHPrBY4Ad", + /// "target_expiry_date": "2023-12-28", "description": "Extending credit validity" + /// } ``` /// /// ## Voiding credits /// @@ -288,10 +308,10 @@ Task CreateEntry( /// /// ## Amendment /// - /// If you'd like to undo a decrement on a credit block, create a ledger - /// entry 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. + /// If you'd like to undo a decrement on a credit block, create a ledger entry + /// 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. /// Task CreateEntryByExternalID( LedgerCreateEntryByExternalIDParams parameters, @@ -311,69 +331,70 @@ Task CreateEntryByExternalID( /// balance. This [paginated endpoint](/api-reference/pagination) lists these /// entries, starting from the most recent ledger entry. /// - /// More details on using Orb's real-time credit feature are [here](/product-catalog/prepurchase). + /// More details on using Orb's real-time credit feature are + /// [here](/product-catalog/prepurchase). /// - /// There are four major types of modifications to credit balance, detailed below. + /// There are four major types of modifications to credit balance, detailed + /// below. /// - /// ## Increment Credits (which optionally expire on a future date) can - /// be added via the API ([Add Ledger Entry](create-ledger-entry)). The ledger - /// entry for such an action will always contain the total eligible starting and - /// ending balance for the customer at the time the entry was added to the ledger. + /// ## Increment Credits (which optionally expire on a future date) can be + /// added via the API ([Add Ledger Entry](create-ledger-entry)). The ledger entry + /// for such an action will always contain the total eligible starting and ending + /// balance for the customer at the time the entry was added to the ledger. /// - /// ## Decrement Deductions can occur as a result of an API call to create - /// a ledger entry (see [Add Ledger Entry](create-ledger-entry)), or automatically - /// as a result of incurring usage. Both ledger entries present the `decrement` - /// entry type. + /// ## Decrement Deductions can occur as a result of an API call to create a + /// ledger entry (see [Add Ledger Entry](create-ledger-entry)), or automatically as + /// a result of incurring usage. Both ledger entries present the `decrement` entry + /// type. /// /// 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. + /// 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. + /// 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 appropriately. As an example, if trial credits with an expiration - /// date of 2 weeks from now are present for a customer, they will be used before - /// any deductions take place from a non-expiring credit block. + /// *soonest expiring credit block* first in order to ensure that all credits are + /// utilized appropriately. As an example, if trial credits with an expiration date + /// of 2 weeks from now are present for a customer, they will be used before any + /// deductions take place from a non-expiring credit block. /// /// If there are multiple blocks with the same expiration date, Orb will - /// deduct from the block with the *lower cost basis* first (e.g. trial credits - /// with a \$0 cost basis before paid credits with a \$5.00 cost basis). + /// deduct from the block with the *lower cost basis* first (e.g. trial credits with + /// a \$0 cost basis before paid credits with a \$5.00 cost basis). /// /// It's also possible for a single usage event's deduction to _span_ credit - /// blocks. In this case, Orb will deduct from the next block, ending at the - /// credit block which consists of unexpiring credits. Each of these deductions - /// will lead to a _separate_ ledger entry, one per credit block that is deducted - /// from. By default, the customer's total credit balance in Orb can be negative - /// as a result of a decrement. - /// - /// ## Expiration change The expiry of credits can be changed as a result - /// of the API (See [Add Ledger Entry](create-ledger-entry)). This will create - /// a ledger entry that specifies the balance as well as the initial and target - /// expiry dates. - /// - /// Note that for this entry type, `starting_balance` will equal `ending_balance`, - /// and the `amount` represents the balance transferred. The credit block linked - /// to the ledger entry is the source credit block from which there was an expiration change. - /// - /// ## Credits expiry When a set of credits expire on pre-set expiration - /// date, the customer's balance automatically reflects this change and adds - /// an entry to the ledger indicating this event. Note that credit expiry should - /// always happen close to a date boundary in the customer's timezone. - /// - /// ## Void initiated Credit blocks can be voided via the API. The `amount` - /// on this entry corresponds to the number of credits that were remaining in - /// the block at time of void. `void_reason` will be populated if the void is - /// created with a reason. - /// - /// ## Void When a set of credits is voided, the customer's balance automatically - /// reflects this change and adds an entry to the ledger indicating this event. - /// - /// ## 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 + /// blocks. In this case, Orb will deduct from the next block, ending at the credit + /// block which consists of unexpiring credits. Each of these deductions will lead + /// to a _separate_ ledger entry, one per credit block that is deducted from. By + /// default, the customer's total credit balance in Orb can be negative as a result + /// of a decrement. + /// + /// ## Expiration change The expiry of credits can be changed as a result of + /// the API (See [Add Ledger Entry](create-ledger-entry)). This will create a ledger + /// entry that specifies the balance as well as the initial and target expiry dates. + /// + /// Note that for this entry type, `starting_balance` will equal + /// `ending_balance`, and the `amount` represents the balance transferred. The + /// credit block linked to the ledger entry is the source credit block from which + /// there was an expiration change. + /// + /// ## Credits expiry When a set of credits expire on pre-set expiration date, + /// the customer's balance automatically reflects this change and adds an entry to + /// the ledger indicating this event. Note that credit expiry should always happen + /// close to a date boundary in the customer's timezone. + /// + /// ## Void initiated Credit blocks can be voided via the API. The `amount` on + /// this entry corresponds to the number of credits that were remaining in the block + /// at time of void. `void_reason` will be populated if the void is created with a + /// reason. + /// + /// ## Void When a set of credits is voided, the customer's balance + /// automatically reflects this change and adds an entry to the ledger indicating + /// this event. + /// + /// ## 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. /// Task ListByExternalID( @@ -403,7 +424,7 @@ public interface ILedgerServiceWithRawResponse ILedgerServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `get /customers/{customer_id}/credits/ledger`, but is otherwise the + /// Returns a raw HTTP response for get /customers/{customer_id}/credits/ledger, but is otherwise the /// same as . /// Task> List( @@ -419,7 +440,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `post /customers/{customer_id}/credits/ledger_entry`, but is otherwise the + /// Returns a raw HTTP response for post /customers/{customer_id}/credits/ledger_entry, but is otherwise the /// same as . /// Task> CreateEntry( @@ -435,7 +456,7 @@ Task> CreateEntry( ); /// - /// Returns a raw HTTP response for `post /customers/external_customer_id/{external_customer_id}/credits/ledger_entry`, but is otherwise the + /// Returns a raw HTTP response for post /customers/external_customer_id/{external_customer_id}/credits/ledger_entry, but is otherwise the /// same as . /// Task> CreateEntryByExternalID( @@ -451,7 +472,7 @@ Task> CreateEntryByExternalI ); /// - /// Returns a raw HTTP response for `get /customers/external_customer_id/{external_customer_id}/credits/ledger`, but is otherwise the + /// Returns a raw HTTP response for get /customers/external_customer_id/{external_customer_id}/credits/ledger, but is otherwise the /// same as . /// Task> ListByExternalID( diff --git a/src/Orb/Services/Customers/Credits/ITopUpService.cs b/src/Orb/Services/Customers/Credits/ITopUpService.cs index c7f766c6d..6fbafc0b1 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 { @@ -29,10 +32,11 @@ public interface ITopUpService /// /// This endpoint allows you to create a new top-up for a specified customer's /// balance. While this top-up is active, the customer's balance will added in - /// increments of the specified amount whenever the balance reaches the specified threshold. + /// increments of the specified amount whenever the balance reaches the specified + /// threshold. /// - /// If a top-up already exists for this customer in the same currency, - /// the existing top-up will be replaced. + /// If a top-up already exists for this customer in the same currency, the + /// existing top-up will be replaced. /// Task Create( TopUpCreateParams parameters, @@ -77,10 +81,11 @@ Task Delete( /// /// This endpoint allows you to create a new top-up for a specified customer's /// balance. While this top-up is active, the customer's balance will added in - /// increments of the specified amount whenever the balance reaches the specified threshold. + /// increments of the specified amount whenever the balance reaches the specified + /// threshold. /// - /// If a top-up already exists for this customer in the same currency, - /// the existing top-up will be replaced. + /// If a top-up already exists for this customer in the same currency, the + /// existing top-up will be replaced. /// Task CreateByExternalID( TopUpCreateByExternalIDParams parameters, @@ -140,7 +145,7 @@ public interface ITopUpServiceWithRawResponse ITopUpServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /customers/{customer_id}/credits/top_ups`, but is otherwise the + /// Returns a raw HTTP response for post /customers/{customer_id}/credits/top_ups, but is otherwise the /// same as . /// Task> Create( @@ -156,7 +161,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `get /customers/{customer_id}/credits/top_ups`, but is otherwise the + /// Returns a raw HTTP response for get /customers/{customer_id}/credits/top_ups, but is otherwise the /// same as . /// Task> List( @@ -172,7 +177,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `delete /customers/{customer_id}/credits/top_ups/{top_up_id}`, but is otherwise the + /// Returns a raw HTTP response for delete /customers/{customer_id}/credits/top_ups/{top_up_id}, but is otherwise the /// same as . /// Task Delete( @@ -188,7 +193,7 @@ Task Delete( ); /// - /// Returns a raw HTTP response for `post /customers/external_customer_id/{external_customer_id}/credits/top_ups`, but is otherwise the + /// Returns a raw HTTP response for post /customers/external_customer_id/{external_customer_id}/credits/top_ups, but is otherwise the /// same as . /// Task> CreateByExternalID( @@ -204,7 +209,7 @@ Task> CreateByExternalID( ); /// - /// Returns a raw HTTP response for `delete /customers/external_customer_id/{external_customer_id}/credits/top_ups/{top_up_id}`, but is otherwise the + /// Returns a raw HTTP response for delete /customers/external_customer_id/{external_customer_id}/credits/top_ups/{top_up_id}, but is otherwise the /// same as . /// Task DeleteByExternalID( @@ -220,7 +225,7 @@ Task DeleteByExternalID( ); /// - /// Returns a raw HTTP response for `get /customers/external_customer_id/{external_customer_id}/credits/top_ups`, but is otherwise the + /// Returns a raw HTTP response for get /customers/external_customer_id/{external_customer_id}/credits/top_ups, but is otherwise the /// same as . /// Task> ListByExternalID( diff --git a/src/Orb/Services/Customers/IBalanceTransactionService.cs b/src/Orb/Services/Customers/IBalanceTransactionService.cs index c2ab67eab..05d7481a1 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 { @@ -27,8 +43,8 @@ public interface IBalanceTransactionService IBalanceTransactionService WithOptions(Func modifier); /// - /// Creates an immutable balance transaction that updates the customer's balance - /// and returns back the newly created transaction. + /// Creates an immutable balance transaction that updates the customer's balance and + /// returns back the newly created transaction. /// Task Create( BalanceTransactionCreateParams parameters, @@ -45,26 +61,26 @@ Task Create( /// /// ## The customer balance /// - /// The customer balance is an amount in the customer's currency, which - /// Orb automatically applies to subsequent invoices. This balance can be adjusted + /// The customer balance is an amount in the customer's currency, which Orb + /// automatically applies to subsequent invoices. This balance can be adjusted /// manually via Orb's webapp on the customer details page. You can use this balance - /// to provide a fixed mid-period credit to the customer. Commonly, this is done - /// due to system downtime/SLA violation, or an adhoc adjustment discussed with - /// the customer. + /// to provide a fixed mid-period credit to the customer. Commonly, this is done due + /// to system downtime/SLA violation, or an adhoc adjustment discussed with the + /// customer. /// /// If the balance is a positive value at the time of invoicing, it represents - /// that the customer has credit that should be used to offset the amount due - /// on the next issued invoice. In this case, Orb will automatically reduce the - /// next invoice by the balance amount, and roll over any remaining balance if - /// the invoice is fully discounted. + /// that the customer has credit that should be used to offset the amount due on the + /// next issued invoice. In this case, Orb will automatically reduce the next + /// invoice by the balance amount, and roll over any remaining balance if the + /// invoice is fully discounted. /// /// If the balance is a negative value at the time of invoicing, Orb will /// increase the invoice's amount due with a positive adjustment, and reset the /// balance to 0. /// /// 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. + /// chronological order for a single customer, providing a complete audit trail of + /// all adjustments and invoice applications. /// Task List( BalanceTransactionListParams parameters, @@ -95,7 +111,7 @@ Func modifier ); /// - /// Returns a raw HTTP response for `post /customers/{customer_id}/balance_transactions`, but is otherwise the + /// Returns a raw HTTP response for post /customers/{customer_id}/balance_transactions, but is otherwise the /// same as . /// Task> Create( @@ -111,7 +127,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `get /customers/{customer_id}/balance_transactions`, but is otherwise the + /// Returns a raw HTTP response for get /customers/{customer_id}/balance_transactions, but is otherwise the /// same as . /// Task> List( diff --git a/src/Orb/Services/Customers/ICostService.cs b/src/Orb/Services/Customers/ICostService.cs index 6aeaf9461..1ea83c652 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 { @@ -27,103 +43,107 @@ public interface ICostService ICostService WithOptions(Func modifier); /// - /// This endpoint is used to fetch a day-by-day snapshot of a customer's costs - /// in Orb, calculated by applying pricing information to the underlying usage - /// (see the [subscription usage endpoint](/api-reference/subscription/fetch-subscription-usage) - /// to fetch usage per metric, in usage units rather than a currency). - /// - /// This endpoint can be leveraged for internal tooling and to provide a - /// more transparent billing experience for your end users: - /// - /// 1. Understand the cost breakdown per line item historically and in real-time - /// for the current billing period. 2. Provide customer visibility into how different - /// services are contributing to the overall invoice with a per-day timeseries - /// (as compared to the [upcoming invoice](/api-reference/invoice/fetch-upcoming-invoice) - /// resource, which represents a snapshot for the current period). 3. Assess - /// how minimums and discounts affect your customers by teasing apart costs directly - /// as a result of usage, as opposed to minimums and discounts at the plan - /// and price level. 4. Gain insight into key customer health metrics, such as - /// the percent utilization of the minimum committed spend. + /// This endpoint is used to fetch a day-by-day snapshot of a customer's costs in + /// Orb, calculated by applying pricing information to the underlying usage (see the + /// [subscription usage + /// endpoint](/api-reference/subscription/fetch-subscription-usage) to fetch usage + /// per metric, in usage units rather than a currency). + /// + /// This endpoint can be leveraged for internal tooling and to provide a more + /// transparent billing experience for your end users: + /// + /// 1. Understand the cost breakdown per line item historically and in + /// real-time for the current billing period. 2. Provide customer visibility into + /// how different services are contributing to the overall invoice with a per-day + /// timeseries (as compared to the [upcoming + /// invoice](/api-reference/invoice/fetch-upcoming-invoice) resource, which + /// represents a snapshot for the current period). 3. Assess how minimums and + /// discounts affect your customers by teasing apart costs directly as a result of + /// usage, as opposed to minimums and discounts at the plan and price level. 4. + /// Gain insight into key customer health metrics, such as the percent utilization + /// of the minimum committed spend. /// /// ## Fetching subscriptions By default, this endpoint fetches the currently /// active subscription for the customer, and returns cost information for the - /// subscription's current billing period, broken down by each participating - /// price. If there are no currently active subscriptions, this will instead default - /// to the most recently active subscription or return an empty series if none - /// are found. For example, if your plan charges for compute hours, job runs, - /// and data syncs, then this endpoint would provide a daily breakdown of your - /// customer's cost for each of those axes. - /// - /// If timeframe bounds are specified, Orb fetches all subscriptions that - /// were active in that timeframe. If two subscriptions overlap on a single day, - /// costs from each price will be summed, and prices for both subscriptions will - /// be included in the breakdown. - /// - /// ## Prepaid plans For plans that include prices which deduct credits - /// rather than accrue in-arrears charges in a billable currency, this endpoint - /// will return the total deduction amount, in credits, for the specified timeframe. + /// subscription's current billing period, broken down by each participating price. + /// If there are no currently active subscriptions, this will instead default to the + /// most recently active subscription or return an empty series if none are found. + /// For example, if your plan charges for compute hours, job runs, and data syncs, + /// then this endpoint would provide a daily breakdown of your customer's cost for + /// each of those axes. + /// + /// If timeframe bounds are specified, Orb fetches all subscriptions that were + /// active in that timeframe. If two subscriptions overlap on a single day, costs + /// from each price will be summed, and prices for both subscriptions will be + /// included in the breakdown. + /// + /// ## Prepaid plans For plans that include prices which deduct credits rather + /// than accrue in-arrears charges in a billable currency, this endpoint will return + /// the total deduction amount, in credits, for the specified timeframe. /// /// ## Cumulative subtotals and totals Since the subtotal and total must /// factor in any billing-period level discounts and minimums, it's most meaningful - /// to consider costs relative to the start of the subscription's billing period. - /// As a result, by default this endpoint returns cumulative totals since the - /// beginning of the billing period. In particular, the `timeframe_start` of - /// a returned timeframe window is *always* the beginning of the billing period - /// and `timeframe_end` is incremented one day at a time to build the result. + /// to consider costs relative to the start of the subscription's billing period. As + /// a result, by default this endpoint returns cumulative totals since the beginning + /// of the billing period. In particular, the `timeframe_start` of a returned + /// timeframe window is *always* the beginning of the billing period and + /// `timeframe_end` is incremented one day at a time to build the result. /// /// A customer that uses a few API calls a day but has a minimum commitment /// might exhibit the following pattern for their subtotal and total in the first - /// few days of the month. Here, we assume that each API call is \$2.50, the customer's - /// plan has a monthly minimum of \$50 for this price, and that the subscription's - /// billing period bounds are aligned to the first of the month: + /// few days of the month. Here, we assume that each API call is \$2.50, the + /// customer's plan has a monthly minimum of \$50 for this price, and that the + /// subscription's billing period bounds are aligned to the first of the month: /// /// | timeframe_start | timeframe_end | Cumulative usage | Subtotal | Total - /// (incl. commitment) | | -----------| ----------- | ----------- | ----------- - /// |----------- | | 2023-02-01 | 2023-02-02 | 9 | \$22.50 | \$50.00 | | 2023-02-01 - /// | 2023-02-03 | 19 | \$47.50 | \$50.00 | | 2023-02-01 | 2023-02-04 | 20 | - /// \$50.00 | \$50.00 | | 2023-02-01 | 2023-02-05 | 28 | \$70.00 | \$70.00 | | - /// 2023-02-01 | 2023-02-06 | 36 | \$90.00 | \$90.00 | + /// (incl. commitment) | | -----------| ----------- | ----------- | ----------- |----------- + /// | | 2023-02-01 | 2023-02-02 | 9 | \$22.50 | \$50.00 | | 2023-02-01 | 2023-02-03 | + /// 19 | \$47.50 | \$50.00 | | 2023-02-01 | 2023-02-04 | 20 | \$50.00 | \$50.00 | | 2023-02-01 + /// | 2023-02-05 | 28 | \$70.00 | \$70.00 | | 2023-02-01 | 2023-02-06 | 36 | \$90.00 + /// | \$90.00 | /// /// ### Periodic values When the query parameter `view_mode=periodic` is /// specified, Orb will return an incremental day-by-day view of costs. In this - /// case, there will always be a one-day difference between `timeframe_start` - /// and `timeframe_end` for the timeframes returned. This is a transform on top - /// of the cumulative costs, calculated by taking the difference of each timeframe - /// with the last. Note that in the above example, the `Total` value would be - /// 0 for the second two data points, since the minimum commitment has not yet - /// been hit and each day is not contributing anything to the total cost. - /// - /// ## Timeframe bounds For an active subscription, both timeframes should - /// be specified in the request. If a subscription starts or ends within the timeframe, - /// the response will only include windows where the subscription is active. If - /// a subscription has ended, no timeframe bounds need to be specified and the - /// response will default to the billing period when the subscription was last active. + /// case, there will always be a one-day difference between `timeframe_start` and + /// `timeframe_end` for the timeframes returned. This is a transform on top of the + /// cumulative costs, calculated by taking the difference of each timeframe with the + /// last. Note that in the above example, the `Total` value would be 0 for the + /// second two data points, since the minimum commitment has not yet been hit and + /// each day is not contributing anything to the total cost. + /// + /// ## Timeframe bounds For an active subscription, both timeframes should be + /// specified in the request. If a subscription starts or ends within the timeframe, + /// the response will only include windows where the subscription is active. If a + /// subscription has ended, no timeframe bounds need to be specified and the + /// response will default to the billing period when the subscription was last + /// active. /// /// As noted above, `timeframe_start` for a given cumulative datapoint is /// always the beginning of the billing period, and `timeframe_end` is incremented - /// one day at a time to construct the response. When a timeframe is passed in - /// that is not aligned to the current subscription's billing period, the response - /// will contain cumulative totals from multiple billing periods. - /// - /// Suppose the queried customer has a subscription aligned to the 15th - /// of every month. If this endpoint is queried with the date range `2023-06-01` - /// - `2023-07-01`, the first data point will represent about half a billing - /// period's worth of costs, accounting for accruals from the start of the billing - /// period and inclusive of the first day of the timeframe (`timeframe_start - /// = 2023-05-15 00:00:00`, `timeframe_end = 2023-06-02 00:00:00`) - /// - /// | datapoint index | timeframe_start | timeframe_end | | ----------- - /// | -----------| ----------- | | 0 | 2023-05-15 | 2023-06-02 | | 1 | 2023-05-15 - /// | 2023-06-03 | | 2 | ... | ... | | 3 | 2023-05-15 | 2023-06-14 | | 4 | 2023-06-15 - /// | 2023-06-16 | | 5 | 2023-06-15 | 2023-06-17 | | 6 | ... | ... | | 7 | 2023-06-15 - /// | 2023-07-01 | - /// - /// You can see this sliced timeframe visualized [here](https://i.imgur.com/TXhYgme.png). - /// - /// ### Matrix prices When a price uses matrix pricing, it's important to - /// view 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. + /// one day at a time to construct the response. When a timeframe is passed in that + /// is not aligned to the current subscription's billing period, the response will + /// contain cumulative totals from multiple billing periods. + /// + /// Suppose the queried customer has a subscription aligned to the 15th of + /// every month. If this endpoint is queried with the date range `2023-06-01` - + /// `2023-07-01`, the first data point will represent about half a billing period's + /// worth of costs, accounting for accruals from the start of the billing period and + /// inclusive of the first day of the timeframe (`timeframe_start = 2023-05-15 + /// 00:00:00`, `timeframe_end = 2023-06-02 00:00:00`) + /// + /// | datapoint index | timeframe_start | timeframe_end | | ----------- | + /// -----------| ----------- | | 0 | 2023-05-15 | 2023-06-02 | | 1 | 2023-05-15 | + /// 2023-06-03 | | 2 | ... | ... | | 3 | 2023-05-15 | 2023-06-14 | | 4 | 2023-06-15 + /// | 2023-06-16 | | 5 | 2023-06-15 | 2023-06-17 | | 6 | ... | ... | | 7 | + /// 2023-06-15 | 2023-07-01 | + /// + /// You can see this sliced timeframe visualized + /// [here](https://i.imgur.com/TXhYgme.png). + /// + /// ### Matrix prices When a price uses matrix pricing, it's important to view + /// 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. /// Task List( CostListParams parameters, @@ -138,103 +158,107 @@ Task List( ); /// - /// This endpoint is used to fetch a day-by-day snapshot of a customer's costs - /// in Orb, calculated by applying pricing information to the underlying usage - /// (see the [subscription usage endpoint](/api-reference/subscription/fetch-subscription-usage) - /// to fetch usage per metric, in usage units rather than a currency). - /// - /// This endpoint can be leveraged for internal tooling and to provide a - /// more transparent billing experience for your end users: - /// - /// 1. Understand the cost breakdown per line item historically and in real-time - /// for the current billing period. 2. Provide customer visibility into how different - /// services are contributing to the overall invoice with a per-day timeseries - /// (as compared to the [upcoming invoice](/api-reference/invoice/fetch-upcoming-invoice) - /// resource, which represents a snapshot for the current period). 3. Assess - /// how minimums and discounts affect your customers by teasing apart costs directly - /// as a result of usage, as opposed to minimums and discounts at the plan - /// and price level. 4. Gain insight into key customer health metrics, such as - /// the percent utilization of the minimum committed spend. + /// This endpoint is used to fetch a day-by-day snapshot of a customer's costs in + /// Orb, calculated by applying pricing information to the underlying usage (see the + /// [subscription usage + /// endpoint](/api-reference/subscription/fetch-subscription-usage) to fetch usage + /// per metric, in usage units rather than a currency). + /// + /// This endpoint can be leveraged for internal tooling and to provide a more + /// transparent billing experience for your end users: + /// + /// 1. Understand the cost breakdown per line item historically and in + /// real-time for the current billing period. 2. Provide customer visibility into + /// how different services are contributing to the overall invoice with a per-day + /// timeseries (as compared to the [upcoming + /// invoice](/api-reference/invoice/fetch-upcoming-invoice) resource, which + /// represents a snapshot for the current period). 3. Assess how minimums and + /// discounts affect your customers by teasing apart costs directly as a result of + /// usage, as opposed to minimums and discounts at the plan and price level. 4. + /// Gain insight into key customer health metrics, such as the percent utilization + /// of the minimum committed spend. /// /// ## Fetching subscriptions By default, this endpoint fetches the currently /// active subscription for the customer, and returns cost information for the - /// subscription's current billing period, broken down by each participating - /// price. If there are no currently active subscriptions, this will instead default - /// to the most recently active subscription or return an empty series if none - /// are found. For example, if your plan charges for compute hours, job runs, - /// and data syncs, then this endpoint would provide a daily breakdown of your - /// customer's cost for each of those axes. - /// - /// If timeframe bounds are specified, Orb fetches all subscriptions that - /// were active in that timeframe. If two subscriptions overlap on a single day, - /// costs from each price will be summed, and prices for both subscriptions will - /// be included in the breakdown. - /// - /// ## Prepaid plans For plans that include prices which deduct credits - /// rather than accrue in-arrears charges in a billable currency, this endpoint - /// will return the total deduction amount, in credits, for the specified timeframe. + /// subscription's current billing period, broken down by each participating price. + /// If there are no currently active subscriptions, this will instead default to the + /// most recently active subscription or return an empty series if none are found. + /// For example, if your plan charges for compute hours, job runs, and data syncs, + /// then this endpoint would provide a daily breakdown of your customer's cost for + /// each of those axes. + /// + /// If timeframe bounds are specified, Orb fetches all subscriptions that were + /// active in that timeframe. If two subscriptions overlap on a single day, costs + /// from each price will be summed, and prices for both subscriptions will be + /// included in the breakdown. + /// + /// ## Prepaid plans For plans that include prices which deduct credits rather + /// than accrue in-arrears charges in a billable currency, this endpoint will return + /// the total deduction amount, in credits, for the specified timeframe. /// /// ## Cumulative subtotals and totals Since the subtotal and total must /// factor in any billing-period level discounts and minimums, it's most meaningful - /// to consider costs relative to the start of the subscription's billing period. - /// As a result, by default this endpoint returns cumulative totals since the - /// beginning of the billing period. In particular, the `timeframe_start` of - /// a returned timeframe window is *always* the beginning of the billing period - /// and `timeframe_end` is incremented one day at a time to build the result. + /// to consider costs relative to the start of the subscription's billing period. As + /// a result, by default this endpoint returns cumulative totals since the beginning + /// of the billing period. In particular, the `timeframe_start` of a returned + /// timeframe window is *always* the beginning of the billing period and + /// `timeframe_end` is incremented one day at a time to build the result. /// /// A customer that uses a few API calls a day but has a minimum commitment /// might exhibit the following pattern for their subtotal and total in the first - /// few days of the month. Here, we assume that each API call is \$2.50, the customer's - /// plan has a monthly minimum of \$50 for this price, and that the subscription's - /// billing period bounds are aligned to the first of the month: + /// few days of the month. Here, we assume that each API call is \$2.50, the + /// customer's plan has a monthly minimum of \$50 for this price, and that the + /// subscription's billing period bounds are aligned to the first of the month: /// /// | timeframe_start | timeframe_end | Cumulative usage | Subtotal | Total - /// (incl. commitment) | | -----------| ----------- | ----------- | ----------- - /// |----------- | | 2023-02-01 | 2023-02-02 | 9 | \$22.50 | \$50.00 | | 2023-02-01 - /// | 2023-02-03 | 19 | \$47.50 | \$50.00 | | 2023-02-01 | 2023-02-04 | 20 | - /// \$50.00 | \$50.00 | | 2023-02-01 | 2023-02-05 | 28 | \$70.00 | \$70.00 | | - /// 2023-02-01 | 2023-02-06 | 36 | \$90.00 | \$90.00 | + /// (incl. commitment) | | -----------| ----------- | ----------- | ----------- |----------- + /// | | 2023-02-01 | 2023-02-02 | 9 | \$22.50 | \$50.00 | | 2023-02-01 | 2023-02-03 | + /// 19 | \$47.50 | \$50.00 | | 2023-02-01 | 2023-02-04 | 20 | \$50.00 | \$50.00 | | 2023-02-01 + /// | 2023-02-05 | 28 | \$70.00 | \$70.00 | | 2023-02-01 | 2023-02-06 | 36 | \$90.00 + /// | \$90.00 | /// /// ### Periodic values When the query parameter `view_mode=periodic` is /// specified, Orb will return an incremental day-by-day view of costs. In this - /// case, there will always be a one-day difference between `timeframe_start` - /// and `timeframe_end` for the timeframes returned. This is a transform on top - /// of the cumulative costs, calculated by taking the difference of each timeframe - /// with the last. Note that in the above example, the `Total` value would be - /// 0 for the second two data points, since the minimum commitment has not yet - /// been hit and each day is not contributing anything to the total cost. - /// - /// ## Timeframe bounds For an active subscription, both timeframes should - /// be specified in the request. If a subscription starts or ends within the timeframe, - /// the response will only include windows where the subscription is active. If - /// a subscription has ended, no timeframe bounds need to be specified and the - /// response will default to the billing period when the subscription was last active. + /// case, there will always be a one-day difference between `timeframe_start` and + /// `timeframe_end` for the timeframes returned. This is a transform on top of the + /// cumulative costs, calculated by taking the difference of each timeframe with the + /// last. Note that in the above example, the `Total` value would be 0 for the + /// second two data points, since the minimum commitment has not yet been hit and + /// each day is not contributing anything to the total cost. + /// + /// ## Timeframe bounds For an active subscription, both timeframes should be + /// specified in the request. If a subscription starts or ends within the timeframe, + /// the response will only include windows where the subscription is active. If a + /// subscription has ended, no timeframe bounds need to be specified and the + /// response will default to the billing period when the subscription was last + /// active. /// /// As noted above, `timeframe_start` for a given cumulative datapoint is /// always the beginning of the billing period, and `timeframe_end` is incremented - /// one day at a time to construct the response. When a timeframe is passed in - /// that is not aligned to the current subscription's billing period, the response - /// will contain cumulative totals from multiple billing periods. - /// - /// Suppose the queried customer has a subscription aligned to the 15th - /// of every month. If this endpoint is queried with the date range `2023-06-01` - /// - `2023-07-01`, the first data point will represent about half a billing - /// period's worth of costs, accounting for accruals from the start of the billing - /// period and inclusive of the first day of the timeframe (`timeframe_start - /// = 2023-05-15 00:00:00`, `timeframe_end = 2023-06-02 00:00:00`) - /// - /// | datapoint index | timeframe_start | timeframe_end | | ----------- - /// | -----------| ----------- | | 0 | 2023-05-15 | 2023-06-02 | | 1 | 2023-05-15 - /// | 2023-06-03 | | 2 | ... | ... | | 3 | 2023-05-15 | 2023-06-14 | | 4 | 2023-06-15 - /// | 2023-06-16 | | 5 | 2023-06-15 | 2023-06-17 | | 6 | ... | ... | | 7 | 2023-06-15 - /// | 2023-07-01 | - /// - /// You can see this sliced timeframe visualized [here](https://i.imgur.com/TXhYgme.png). - /// - /// ### Matrix prices When a price uses matrix pricing, it's important to - /// view 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. + /// one day at a time to construct the response. When a timeframe is passed in that + /// is not aligned to the current subscription's billing period, the response will + /// contain cumulative totals from multiple billing periods. + /// + /// Suppose the queried customer has a subscription aligned to the 15th of + /// every month. If this endpoint is queried with the date range `2023-06-01` - + /// `2023-07-01`, the first data point will represent about half a billing period's + /// worth of costs, accounting for accruals from the start of the billing period and + /// inclusive of the first day of the timeframe (`timeframe_start = 2023-05-15 + /// 00:00:00`, `timeframe_end = 2023-06-02 00:00:00`) + /// + /// | datapoint index | timeframe_start | timeframe_end | | ----------- | + /// -----------| ----------- | | 0 | 2023-05-15 | 2023-06-02 | | 1 | 2023-05-15 | + /// 2023-06-03 | | 2 | ... | ... | | 3 | 2023-05-15 | 2023-06-14 | | 4 | 2023-06-15 + /// | 2023-06-16 | | 5 | 2023-06-15 | 2023-06-17 | | 6 | ... | ... | | 7 | + /// 2023-06-15 | 2023-07-01 | + /// + /// You can see this sliced timeframe visualized + /// [here](https://i.imgur.com/TXhYgme.png). + /// + /// ### Matrix prices When a price uses matrix pricing, it's important to view + /// 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. /// Task ListByExternalID( CostListByExternalIDParams parameters, @@ -263,7 +287,7 @@ public interface ICostServiceWithRawResponse ICostServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `get /customers/{customer_id}/costs`, but is otherwise the + /// Returns a raw HTTP response for get /customers/{customer_id}/costs, but is otherwise the /// same as . /// Task> List( @@ -279,7 +303,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `get /customers/external_customer_id/{external_customer_id}/costs`, but is otherwise the + /// Returns a raw HTTP response for get /customers/external_customer_id/{external_customer_id}/costs, but is otherwise the /// same as . /// Task> ListByExternalID( diff --git a/src/Orb/Services/Customers/ICreditService.cs b/src/Orb/Services/Customers/ICreditService.cs index 71044e6ab..d7c402202 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 { @@ -37,8 +40,13 @@ public interface ICreditService /// If `include_all_blocks` is set to `true`, all credit blocks (including /// expired and depleted blocks) will be included in the response. /// - /// Note that `currency` defaults to credits if not specified. To use a - /// real world currency, set `currency` to an ISO 4217 string. + /// 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, @@ -58,8 +66,13 @@ Task List( /// If `include_all_blocks` is set to `true`, all credit blocks (including /// expired and depleted blocks) will be included in the response. /// - /// Note that `currency` defaults to credits if not specified. To use a - /// real world currency, set `currency` to an ISO 4217 string. + /// 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, @@ -92,7 +105,7 @@ public interface ICreditServiceWithRawResponse ITopUpServiceWithRawResponse TopUps { get; } /// - /// Returns a raw HTTP response for `get /customers/{customer_id}/credits`, but is otherwise the + /// Returns a raw HTTP response for get /customers/{customer_id}/credits, but is otherwise the /// same as . /// Task> List( @@ -108,7 +121,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `get /customers/external_customer_id/{external_customer_id}/credits`, but is otherwise the + /// Returns a raw HTTP response for get /customers/external_customer_id/{external_customer_id}/credits, but is otherwise the /// same as . /// Task> ListByExternalID( diff --git a/src/Orb/Services/DimensionalPriceGroups/IExternalDimensionalPriceGroupIDService.cs b/src/Orb/Services/DimensionalPriceGroups/IExternalDimensionalPriceGroupIDService.cs index a62abd3a3..e09c7a890 100644 --- a/src/Orb/Services/DimensionalPriceGroups/IExternalDimensionalPriceGroupIDService.cs +++ b/src/Orb/Services/DimensionalPriceGroups/IExternalDimensionalPriceGroupIDService.cs @@ -46,8 +46,8 @@ Task Retrieve( /// /// 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. + /// and `metadata` of an existing dimensional price group. Other fields on a + /// dimensional price group are currently immutable. /// Task Update( ExternalDimensionalPriceGroupIDUpdateParams parameters, @@ -78,7 +78,7 @@ Func modifier ); /// - /// Returns a raw HTTP response for `get /dimensional_price_groups/external_dimensional_price_group_id/{external_dimensional_price_group_id}`, but is otherwise the + /// Returns a raw HTTP response for get /dimensional_price_groups/external_dimensional_price_group_id/{external_dimensional_price_group_id}, but is otherwise the /// same as . /// Task> Retrieve( @@ -94,7 +94,7 @@ Task> Retrieve( ); /// - /// Returns a raw HTTP response for `put /dimensional_price_groups/external_dimensional_price_group_id/{external_dimensional_price_group_id}`, but is otherwise the + /// Returns a raw HTTP response for put /dimensional_price_groups/external_dimensional_price_group_id/{external_dimensional_price_group_id}, but is otherwise the /// same as . /// Task> Update( diff --git a/src/Orb/Services/Events/IBackfillService.cs b/src/Orb/Services/Events/IBackfillService.cs index 5cbafef73..e7abc6961 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 { @@ -27,40 +31,42 @@ public interface IBackfillService IBackfillService WithOptions(Func modifier); /// - /// Creating the backfill enables adding or replacing past events, even those - /// that are older than the ingestion grace period. Performing a backfill in Orb - /// involves 3 steps: + /// Creating the backfill enables adding or replacing past events, even those that + /// are older than the ingestion grace period. Performing a backfill in Orb involves + /// 3 steps: /// - /// 1. Create the backfill, specifying its parameters. 2. [Ingest](ingest) - /// usage events, referencing the backfill (query parameter `backfill_id`). 3. - /// [Close](close-backfill) the backfill, propagating the update in past usage - /// throughout Orb. + /// 1. Create the backfill, specifying its parameters. 2. + /// [Ingest](/api-reference/event/ingest-events) usage events, referencing the + /// backfill (query parameter `backfill_id`). 3. [Close](close-backfill) the + /// backfill, propagating the update in past usage throughout Orb. /// - /// Changes from a backfill are not reflected until the backfill is closed, - /// so you won’t need to worry about your customers seeing partially updated - /// usage data. Backfills are also reversible, so you’ll be able to revert a backfill - /// if you’ve made a mistake. + /// Changes from a backfill are not reflected until the backfill is closed, so + /// you won’t need to worry about your customers seeing partially updated usage + /// data. Backfills are also reversible, so you’ll be able to revert a backfill if + /// you’ve made a mistake. /// - /// This endpoint will return a backfill object, which contains an `id`. - /// That `id` can then be used as the `backfill_id` query parameter to the event + /// This endpoint will return a backfill object, which contains an `id`. That + /// `id` can then be used as the `backfill_id` query parameter to the event /// ingestion endpoint to associate ingested events with this backfill. The effects /// (e.g. updated usage graphs) of this backfill will not take place until the /// backfill is closed. /// - /// If the `replace_existing_events` is `true`, existing events in the backfill's - /// timeframe will be replaced with the newly ingested events associated with - /// the backfill. If `false`, newly ingested events will be added to the existing events. + /// If the `replace_existing_events` is `true`, existing events in the + /// backfill's timeframe will be replaced with the newly ingested events associated + /// with the backfill. If `false`, newly ingested events will be added to the + /// existing events. /// /// If a `customer_id` or `external_customer_id` is specified, the backfill /// will only affect events for that customer. If neither is specified, the backfill /// will affect all customers. /// /// When `replace_existing_events` is `true`, this indicates that existing - /// events in the timeframe should no longer be counted towards invoiced usage. - /// In this scenario, the parameter `deprecation_filter` can be optionally added - /// which enables filtering using [computed properties](/extensibility/advanced-metrics#computed-properties). - /// The expressiveness of computed properties allows you to deprecate existing - /// events based on both a period of time and specific property values. + /// events in the timeframe should no longer be counted towards invoiced usage. In + /// this scenario, the parameter `deprecation_filter` can be optionally added which + /// enables filtering using [computed + /// properties](/extensibility/advanced-metrics#computed-properties). The + /// expressiveness of computed properties allows you to deprecate existing events + /// based on both a period of time and specific property values. /// /// You may not have multiple backfills in a pending or pending_revert state /// with overlapping timeframes. @@ -74,9 +80,9 @@ Task Create( /// This endpoint returns a list of all backfills in a list format. /// /// The list of backfills is ordered starting from the most recently created - /// 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). + /// backfill. The response also includes + /// [`pagination_metadata`](/api-reference/pagination), which lets the caller + /// retrieve the next page of results if they exist. /// Task List( BackfillListParams? parameters = null, @@ -118,12 +124,12 @@ Task Fetch( /// /// Reverting a backfill undoes all the effects of closing the backfill. If the - /// backfill is reflected, the status will transition to `pending_revert` while - /// the effects of the backfill are undone. Once all effects are undone, the - /// backfill will transition to `reverted`. + /// backfill is reflected, the status will transition to `pending_revert` while the + /// effects of the backfill are undone. Once all effects are undone, the backfill + /// will transition to `reverted`. /// - /// 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`. + /// 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`. /// Task Revert( BackfillRevertParams parameters, @@ -152,7 +158,7 @@ public interface IBackfillServiceWithRawResponse IBackfillServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /events/backfills`, but is otherwise the + /// Returns a raw HTTP response for post /events/backfills, but is otherwise the /// same as . /// Task> Create( @@ -161,7 +167,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `get /events/backfills`, but is otherwise the + /// Returns a raw HTTP response for get /events/backfills, but is otherwise the /// same as . /// Task> List( @@ -170,7 +176,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `post /events/backfills/{backfill_id}/close`, but is otherwise the + /// Returns a raw HTTP response for post /events/backfills/{backfill_id}/close, but is otherwise the /// same as . /// Task> Close( @@ -186,7 +192,7 @@ Task> Close( ); /// - /// Returns a raw HTTP response for `get /events/backfills/{backfill_id}`, but is otherwise the + /// Returns a raw HTTP response for get /events/backfills/{backfill_id}, but is otherwise the /// same as . /// Task> Fetch( @@ -202,7 +208,7 @@ Task> Fetch( ); /// - /// Returns a raw HTTP response for `post /events/backfills/{backfill_id}/revert`, but is otherwise the + /// Returns a raw HTTP response for post /events/backfills/{backfill_id}/revert, but is otherwise the /// same as . /// Task> Revert( diff --git a/src/Orb/Services/Events/IVolumeService.cs b/src/Orb/Services/Events/IVolumeService.cs index 4f42b7a76..2b06ce66c 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 { @@ -27,17 +31,19 @@ public interface IVolumeService IVolumeService WithOptions(Func modifier); /// - /// This endpoint returns the event volume for an account in a [paginated list format](/api-reference/pagination). + /// This endpoint returns the event volume for an account in a [paginated list + /// format](/api-reference/pagination). /// - /// The event volume is aggregated by the hour and the [timestamp](/api-reference/event/ingest-events) - /// field is used to determine which hour an event is associated with. Note, - /// this means that late-arriving events increment the volume count for the hour - /// window the timestamp is in, not the latest hour window. + /// The event volume is aggregated by the hour and the + /// [timestamp](/api-reference/event/ingest-events) field is used to determine which + /// hour an event is associated with. Note, this means that late-arriving events + /// increment the volume count for the hour window the timestamp is in, not the + /// latest hour window. /// - /// Each item in the response contains the count of events aggregated by - /// the 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. + /// Each item in the response contains the count of events aggregated by the + /// 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. /// Task List( VolumeListParams parameters, @@ -59,7 +65,7 @@ public interface IVolumeServiceWithRawResponse IVolumeServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `get /events/volume`, but is otherwise the + /// Returns a raw HTTP response for get /events/volume, but is otherwise the /// same as . /// Task> List( diff --git a/src/Orb/Services/IAlertService.cs b/src/Orb/Services/IAlertService.cs index fe2b3ae13..210b9bf2f 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 { @@ -56,14 +61,15 @@ Task Update( /// /// This endpoint returns a list of alerts within Orb. /// - /// The request must specify one of `customer_id`, `external_customer_id`, - /// or `subscription_id`. + /// The request must specify one of `customer_id`, `external_customer_id`, or + /// `subscription_id`. /// /// If querying by subscription_id, the endpoint will return the subscription /// level alerts as well as the plan level alerts associated with the subscription. /// /// The list of alerts is ordered starting from the most recently created - /// alert. This endpoint follows Orb's [standardized pagination format](/api-reference/pagination). + /// alert. This endpoint follows Orb's [standardized pagination + /// format](/api-reference/pagination). /// Task List( AlertListParams? parameters = null, @@ -71,13 +77,14 @@ Task List( ); /// - /// This endpoint creates a new alert to monitor a customer's credit balance. - /// There are three types of alerts that can be scoped to customers: `credit_balance_depleted`, - /// `credit_balance_dropped`, and `credit_balance_recovered`. Customers can have - /// a 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. + /// This endpoint creates a new alert to monitor a customer's credit balance. There + /// are three types of alerts that can be scoped to customers: + /// `credit_balance_depleted`, `credit_balance_dropped`, and + /// `credit_balance_recovered`. Customers can have a 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. /// Task CreateForCustomer( AlertCreateForCustomerParams parameters, @@ -92,13 +99,14 @@ Task CreateForCustomer( ); /// - /// This endpoint creates a new alert to monitor a customer's credit balance. - /// There are three types of alerts that can be scoped to customers: `credit_balance_depleted`, - /// `credit_balance_dropped`, and `credit_balance_recovered`. Customers can have - /// a 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. + /// This endpoint creates a new alert to monitor a customer's credit balance. There + /// are three types of alerts that can be scoped to customers: + /// `credit_balance_depleted`, `credit_balance_dropped`, and + /// `credit_balance_recovered`. Customers can have a 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. /// Task CreateForExternalCustomer( AlertCreateForExternalCustomerParams parameters, @@ -115,15 +123,15 @@ Task CreateForExternalCustomer( /// /// This endpoint is used to create alerts at the subscription level. /// - /// Subscription level alerts can be one of two types: `usage_exceeded` - /// or `cost_exceeded`. A `usage_exceeded` alert is scoped to a particular metric - /// and is triggered when the usage of that metric exceeds predefined thresholds - /// during the current billing cycle. A `cost_exceeded` alert is triggered when - /// the total amount due during the current billing cycle surpasses predefined - /// thresholds. `cost_exceeded` alerts do not include burndown of pre-purchase - /// credits. Each subscription can have one `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. + /// Subscription level alerts can be one of two types: `usage_exceeded` or + /// `cost_exceeded`. A `usage_exceeded` alert is scoped to a particular metric and + /// is triggered when the usage of that metric exceeds predefined thresholds during + /// the current billing cycle. A `cost_exceeded` alert is triggered when the total + /// amount due during the current billing cycle surpasses predefined thresholds. + /// `cost_exceeded` alerts do not include burndown of pre-purchase credits. Each + /// subscription can have one `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. /// Task CreateForSubscription( AlertCreateForSubscriptionParams parameters, @@ -138,9 +146,9 @@ Task CreateForSubscription( ); /// - /// 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. + /// 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. /// Task Disable( AlertDisableParams parameters, @@ -155,9 +163,9 @@ Task Disable( ); /// - /// 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. + /// 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. /// Task Enable(AlertEnableParams parameters, CancellationToken cancellationToken = default); @@ -183,7 +191,7 @@ public interface IAlertServiceWithRawResponse IAlertServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `get /alerts/{alert_id}`, but is otherwise the + /// Returns a raw HTTP response for get /alerts/{alert_id}, but is otherwise the /// same as . /// Task> Retrieve( @@ -199,7 +207,7 @@ Task> Retrieve( ); /// - /// Returns a raw HTTP response for `put /alerts/{alert_configuration_id}`, but is otherwise the + /// Returns a raw HTTP response for put /alerts/{alert_configuration_id}, but is otherwise the /// same as . /// Task> Update( @@ -215,7 +223,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `get /alerts`, but is otherwise the + /// Returns a raw HTTP response for get /alerts, but is otherwise the /// same as . /// Task> List( @@ -224,7 +232,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `post /alerts/customer_id/{customer_id}`, but is otherwise the + /// Returns a raw HTTP response for post /alerts/customer_id/{customer_id}, but is otherwise the /// same as . /// Task> CreateForCustomer( @@ -240,7 +248,7 @@ Task> CreateForCustomer( ); /// - /// Returns a raw HTTP response for `post /alerts/external_customer_id/{external_customer_id}`, but is otherwise the + /// Returns a raw HTTP response for post /alerts/external_customer_id/{external_customer_id}, but is otherwise the /// same as . /// Task> CreateForExternalCustomer( @@ -256,7 +264,7 @@ Task> CreateForExternalCustomer( ); /// - /// Returns a raw HTTP response for `post /alerts/subscription_id/{subscription_id}`, but is otherwise the + /// Returns a raw HTTP response for post /alerts/subscription_id/{subscription_id}, but is otherwise the /// same as . /// Task> CreateForSubscription( @@ -272,7 +280,7 @@ Task> CreateForSubscription( ); /// - /// Returns a raw HTTP response for `post /alerts/{alert_configuration_id}/disable`, but is otherwise the + /// Returns a raw HTTP response for post /alerts/{alert_configuration_id}/disable, but is otherwise the /// same as . /// Task> Disable( @@ -288,7 +296,7 @@ Task> Disable( ); /// - /// Returns a raw HTTP response for `post /alerts/{alert_configuration_id}/enable`, but is otherwise the + /// Returns a raw HTTP response for post /alerts/{alert_configuration_id}/enable, but is otherwise the /// same as . /// Task> Enable( diff --git a/src/Orb/Services/IBetaService.cs b/src/Orb/Services/IBetaService.cs index 4b42c1c9d..8eccad363 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 { @@ -93,7 +97,7 @@ public interface IBetaServiceWithRawResponse IExternalPlanIDServiceWithRawResponse ExternalPlanID { get; } /// - /// Returns a raw HTTP response for `post /plans/{plan_id}/versions`, but is otherwise the + /// Returns a raw HTTP response for post /plans/{plan_id}/versions, but is otherwise the /// same as . /// Task> CreatePlanVersion( @@ -109,7 +113,7 @@ Task> CreatePlanVersion( ); /// - /// Returns a raw HTTP response for `get /plans/{plan_id}/versions/{version}`, but is otherwise the + /// Returns a raw HTTP response for get /plans/{plan_id}/versions/{version}, but is otherwise the /// same as . /// Task> FetchPlanVersion( @@ -125,7 +129,7 @@ Task> FetchPlanVersion( ); /// - /// Returns a raw HTTP response for `post /plans/{plan_id}/set_default_version`, but is otherwise the + /// Returns a raw HTTP response for post /plans/{plan_id}/set_default_version, but is otherwise the /// same as . /// Task> SetDefaultPlanVersion( diff --git a/src/Orb/Services/ICouponService.cs b/src/Orb/Services/ICouponService.cs index bb02e0542..126bc5ae0 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 { @@ -30,8 +35,8 @@ public interface ICouponService Coupons::ISubscriptionService Subscriptions { get; } /// - /// This endpoint allows the creation of coupons, which can then be redeemed - /// at subscription creation or plan change. + /// This endpoint allows the creation of coupons, which can then be redeemed at + /// subscription creation or plan change. /// Task Create( CouponCreateParams parameters, @@ -43,8 +48,7 @@ Task Create( /// /// The list of coupons is ordered starting from the most recently created /// 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. + /// retrieve the next page of results if they exist. /// Task List( CouponListParams? parameters = null, @@ -52,9 +56,9 @@ Task List( ); /// - /// 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. + /// 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. /// Task Archive( CouponArchiveParams parameters, @@ -70,7 +74,8 @@ Task Archive( /// /// 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. + /// code, use the [List coupons](list-coupons) endpoint with the redemption_code + /// parameter. /// Task Fetch(CouponFetchParams parameters, CancellationToken cancellationToken = default); @@ -98,7 +103,7 @@ public interface ICouponServiceWithRawResponse Coupons::ISubscriptionServiceWithRawResponse Subscriptions { get; } /// - /// Returns a raw HTTP response for `post /coupons`, but is otherwise the + /// Returns a raw HTTP response for post /coupons, but is otherwise the /// same as . /// Task> Create( @@ -107,7 +112,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `get /coupons`, but is otherwise the + /// Returns a raw HTTP response for get /coupons, but is otherwise the /// same as . /// Task> List( @@ -116,7 +121,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `post /coupons/{coupon_id}/archive`, but is otherwise the + /// Returns a raw HTTP response for post /coupons/{coupon_id}/archive, but is otherwise the /// same as . /// Task> Archive( @@ -132,7 +137,7 @@ Task> Archive( ); /// - /// Returns a raw HTTP response for `get /coupons/{coupon_id}`, but is otherwise the + /// Returns a raw HTTP response for get /coupons/{coupon_id}, but is otherwise the /// same as . /// Task> Fetch( diff --git a/src/Orb/Services/ICreditBlockService.cs b/src/Orb/Services/ICreditBlockService.cs index c2d358645..822ba4de3 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 { @@ -45,14 +48,14 @@ Task Retrieve( /// This endpoint deletes a credit block by its ID. /// /// When a credit block is deleted: - The block is removed from the customer's - /// credit ledger. - Any usage of the credit block is reversed, and the ledger - /// is replayed as if the block never existed. - If invoices were generated from - /// the purchase of the credit block, they will be deleted if in draft status, - /// voided if issued, or a credit note will be issued if the invoice is paid. + /// credit ledger. - Any usage of the credit block is reversed, and the ledger is + /// replayed as if the block never existed. - If invoices were generated from the + /// purchase of the credit block, they will be deleted if in draft status, voided + /// if issued, or a credit note will be issued if the invoice is paid. /// - /// 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. + /// 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. /// Task Delete(CreditBlockDeleteParams parameters, CancellationToken cancellationToken = default); @@ -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 + ); } /// @@ -78,7 +109,7 @@ public interface ICreditBlockServiceWithRawResponse ICreditBlockServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `get /credit_blocks/{block_id}`, but is otherwise the + /// Returns a raw HTTP response for get /credit_blocks/{block_id}, but is otherwise the /// same as . /// Task> Retrieve( @@ -94,7 +125,7 @@ Task> Retrieve( ); /// - /// Returns a raw HTTP response for `delete /credit_blocks/{block_id}`, but is otherwise the + /// Returns a raw HTTP response for delete /credit_blocks/{block_id}, but is otherwise the /// same as . /// Task Delete( @@ -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..bb30e8c06 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 { @@ -28,7 +31,8 @@ public interface ICreditNoteService ICreditNoteService WithOptions(Func modifier); /// - /// This endpoint is used to create a single [`Credit Note`](/invoicing/credit-notes). + /// This endpoint is used to create a single [`Credit + /// Note`](/invoicing/credit-notes). /// /// The credit note service period configuration supports two explicit modes: /// @@ -41,18 +45,18 @@ public interface ICreditNoteService /// 3. Default behavior: If no service periods are specified (neither global /// nor individual), the original invoice line item service periods will be used. /// - /// Note: Mixing global and individual service periods in the same request - /// is not allowed to prevent confusion. + /// Note: Mixing global and individual service periods in the same request is + /// not allowed to prevent confusion. /// - /// Service period dates are normalized to the start of the day in the customer's - /// timezone to ensure consistent handling across different timezones. + /// Service period dates are normalized to the start of the day in the + /// customer's timezone to ensure consistent handling across different timezones. /// /// Date Format: Use start_date and end_date with format "YYYY-MM-DD" (e.g., /// "2023-09-22") to match other Orb APIs like /v1/invoice_line_items. /// - /// 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: 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). /// Task Create( CreditNoteCreateParams parameters, @@ -61,8 +65,8 @@ Task Create( /// /// 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`. + /// subscription_id, or external_customer_id. The credit notes will be returned in + /// reverse chronological order by `creation_time`. /// Task List( CreditNoteListParams? parameters = null, @@ -100,7 +104,7 @@ public interface ICreditNoteServiceWithRawResponse ICreditNoteServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /credit_notes`, but is otherwise the + /// Returns a raw HTTP response for post /credit_notes, but is otherwise the /// same as . /// Task> Create( @@ -109,7 +113,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `get /credit_notes`, but is otherwise the + /// Returns a raw HTTP response for get /credit_notes, but is otherwise the /// same as . /// Task> List( @@ -118,7 +122,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `get /credit_notes/{credit_note_id}`, but is otherwise the + /// Returns a raw HTTP response for get /credit_notes/{credit_note_id}, but is otherwise the /// same as . /// Task> Fetch( diff --git a/src/Orb/Services/ICustomerService.cs b/src/Orb/Services/ICustomerService.cs index a284faac1..b04402419 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 { @@ -39,10 +55,11 @@ public interface ICustomerService /// of the customer resource. /// /// This endpoint is critical in the following Orb functionality: * Automated - /// charges can be configured by setting `payment_provider` and `payment_provider_id` - /// 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 + /// charges can be configured by setting `payment_provider` and + /// `payment_provider_id` 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 /// Task Create( CustomerCreateParams parameters, @@ -50,10 +67,12 @@ 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. + /// 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`, + /// `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, @@ -70,9 +89,11 @@ Task Update( /// /// This endpoint returns a list of all customers for an account. The list of /// customers is ordered starting from the most recently created customer. This - /// endpoint follows Orb's [standardized pagination format](/api-reference/pagination). + /// endpoint follows Orb's [standardized pagination + /// format](/api-reference/pagination). /// - /// See [Customer](/core-concepts##customer) for an overview of the customer model. + /// See [Customer](/core-concepts##customer) for an overview of the customer + /// model. /// Task List( CustomerListParams? parameters = null, @@ -82,16 +103,16 @@ Task List( /// /// This performs a deletion of this customer, its subscriptions, and its invoices, /// provided the customer does not have any issued invoices. Customers with issued - /// invoices cannot be deleted. This operation is irreversible. Note that this - /// is a _soft_ deletion, but the data will be inaccessible through the API and - /// Orb dashboard. + /// invoices cannot be deleted. This operation is irreversible. Note that this is a + /// _soft_ deletion, but the data will be inaccessible through the API and Orb + /// dashboard. /// /// For a hard-deletion, please reach out to the Orb team directly. /// - /// **Note**: This operation happens asynchronously and can be expected - /// to 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**: This operation happens asynchronously and can be expected to + /// 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. /// Task Delete(CustomerDeleteParams parameters, CancellationToken cancellationToken = default); @@ -126,8 +147,8 @@ Task Fetch( /// This endpoint is used to fetch 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 - /// [Get Customer](fetch-customer). + /// Note that the resource and semantics of this endpoint exactly mirror [Get + /// Customer](fetch-customer). /// Task FetchByExternalID( CustomerFetchByExternalIDParams parameters, @@ -145,8 +166,8 @@ Task FetchByExternalID( /// Sync Orb's payment methods for the customer with their gateway. /// /// This method can be called before taking an action that may cause the - /// customer to be charged, ensuring that the most up-to-date payment method - /// is charged. + /// customer to be charged, ensuring that the most up-to-date payment method is + /// charged. /// /// **Note**: This functionality is currently only available for Stripe. /// @@ -166,8 +187,8 @@ Task SyncPaymentMethodsFromGateway( /// Sync Orb's payment methods for the customer with their gateway. /// /// This method can be called before taking an action that may cause the - /// customer to be charged, ensuring that the most up-to-date payment method - /// is charged. + /// customer to be charged, ensuring that the most up-to-date payment method is + /// charged. /// /// **Note**: This functionality is currently only available for Stripe. /// @@ -185,8 +206,9 @@ Task SyncPaymentMethodsFromGatewayByExternalCustomerID( /// /// 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). + /// (see [Customer ID Aliases](/events-and-metrics/customer-aliases)). Note that the + /// resource and semantics of this endpoint exactly mirror [Update + /// Customer](update-customer). /// Task UpdateByExternalID( CustomerUpdateByExternalIDParams parameters, @@ -221,7 +243,7 @@ public interface ICustomerServiceWithRawResponse IBalanceTransactionServiceWithRawResponse BalanceTransactions { get; } /// - /// Returns a raw HTTP response for `post /customers`, but is otherwise the + /// Returns a raw HTTP response for post /customers, but is otherwise the /// same as . /// Task> Create( @@ -230,7 +252,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `put /customers/{customer_id}`, but is otherwise the + /// Returns a raw HTTP response for put /customers/{customer_id}, but is otherwise the /// same as . /// Task> Update( @@ -246,7 +268,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `get /customers`, but is otherwise the + /// Returns a raw HTTP response for get /customers, but is otherwise the /// same as . /// Task> List( @@ -255,7 +277,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `delete /customers/{customer_id}`, but is otherwise the + /// Returns a raw HTTP response for delete /customers/{customer_id}, but is otherwise the /// same as . /// Task Delete( @@ -271,7 +293,7 @@ Task Delete( ); /// - /// Returns a raw HTTP response for `get /customers/{customer_id}`, but is otherwise the + /// Returns a raw HTTP response for get /customers/{customer_id}, but is otherwise the /// same as . /// Task> Fetch( @@ -287,7 +309,7 @@ Task> Fetch( ); /// - /// Returns a raw HTTP response for `get /customers/external_customer_id/{external_customer_id}`, but is otherwise the + /// Returns a raw HTTP response for get /customers/external_customer_id/{external_customer_id}, but is otherwise the /// same as . /// Task> FetchByExternalID( @@ -303,7 +325,7 @@ Task> FetchByExternalID( ); /// - /// Returns a raw HTTP response for `post /customers/{customer_id}/sync_payment_methods_from_gateway`, but is otherwise the + /// Returns a raw HTTP response for post /customers/{customer_id}/sync_payment_methods_from_gateway, but is otherwise the /// same as . /// Task SyncPaymentMethodsFromGateway( @@ -319,7 +341,7 @@ Task SyncPaymentMethodsFromGateway( ); /// - /// Returns a raw HTTP response for `post /customers/external_customer_id/{external_customer_id}/sync_payment_methods_from_gateway`, but is otherwise the + /// Returns a raw HTTP response for post /customers/external_customer_id/{external_customer_id}/sync_payment_methods_from_gateway, but is otherwise the /// same as . /// Task SyncPaymentMethodsFromGatewayByExternalCustomerID( @@ -335,7 +357,7 @@ Task SyncPaymentMethodsFromGatewayByExternalCustomerID( ); /// - /// Returns a raw HTTP response for `put /customers/external_customer_id/{external_customer_id}`, but is otherwise the + /// Returns a raw HTTP response for put /customers/external_customer_id/{external_customer_id}, but is otherwise the /// same as . /// Task> UpdateByExternalID( diff --git a/src/Orb/Services/IDimensionalPriceGroupService.cs b/src/Orb/Services/IDimensionalPriceGroupService.cs index 67a1f2ead..53fcb612e 100644 --- a/src/Orb/Services/IDimensionalPriceGroupService.cs +++ b/src/Orb/Services/IDimensionalPriceGroupService.cs @@ -31,14 +31,13 @@ public interface IDimensionalPriceGroupService /// /// A dimensional price group is used to partition the result of a billable metric - /// by a set of dimensions. Prices in a price group must specify the partition - /// used to derive their usage. + /// by a set of dimensions. Prices in a price group must specify the partition used + /// to derive their usage. /// - /// For example, suppose we have a billable metric that measures the number - /// 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. + /// For example, suppose we have a billable metric that measures the number 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. /// Task Create( DimensionalPriceGroupCreateParams parameters, @@ -62,8 +61,8 @@ Task Retrieve( /// /// 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. + /// and `metadata` of an existing dimensional price group. Other fields on a + /// dimensional price group are currently immutable. /// Task Update( DimensionalPriceGroupUpdateParams parameters, @@ -104,7 +103,7 @@ Func modifier IExternalDimensionalPriceGroupIDServiceWithRawResponse ExternalDimensionalPriceGroupID { get; } /// - /// Returns a raw HTTP response for `post /dimensional_price_groups`, but is otherwise the + /// Returns a raw HTTP response for post /dimensional_price_groups, but is otherwise the /// same as . /// Task> Create( @@ -113,7 +112,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `get /dimensional_price_groups/{dimensional_price_group_id}`, but is otherwise the + /// Returns a raw HTTP response for get /dimensional_price_groups/{dimensional_price_group_id}, but is otherwise the /// same as . /// Task> Retrieve( @@ -129,7 +128,7 @@ Task> Retrieve( ); /// - /// Returns a raw HTTP response for `put /dimensional_price_groups/{dimensional_price_group_id}`, but is otherwise the + /// Returns a raw HTTP response for put /dimensional_price_groups/{dimensional_price_group_id}, but is otherwise the /// same as . /// Task> Update( @@ -145,7 +144,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `get /dimensional_price_groups`, but is otherwise the + /// Returns a raw HTTP response for get /dimensional_price_groups, but is otherwise the /// same as . /// Task> List( diff --git a/src/Orb/Services/IEventService.cs b/src/Orb/Services/IEventService.cs index 5a1400051..27b0f5328 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 { @@ -33,44 +37,44 @@ public interface IEventService /// /// This endpoint is used to amend a single usage event with a given `event_id`. - /// `event_id` refers to the `idempotency_key` passed in during ingestion. The - /// event will maintain its existing `event_id` after the amendment. - /// - /// This endpoint will mark the existing event as ignored, and Orb will - /// only use the new event passed in the body of this request as the source of - /// truth for that `event_id`. Note that a single event can be amended any number - /// of times, so the same event can be overwritten in subsequent calls to this - /// endpoint. Only a single event with a given `event_id` will be considered - /// the source of truth at any given time. - /// - /// This is a powerful and audit-safe mechanism to retroactively update - /// a single event in cases where you need to: * update an event with new metadata - /// as you iterate on your pricing model * update an event based on the result - /// of an external API call (e.g. call to a payment gateway succeeded or failed) - /// - /// This amendment API is always audit-safe. The process will still retain - /// the original event, though it will be ignored for billing calculations. For - /// auditing and data fidelity purposes, Orb never overwrites or permanently deletes - /// ingested usage data. + /// `event_id` refers to the `idempotency_key` passed in during ingestion. The event + /// will maintain its existing `event_id` after the amendment. + /// + /// This endpoint will mark the existing event as ignored, and Orb will only + /// use the new event passed in the body of this request as the source of truth for + /// that `event_id`. Note that a single event can be amended any number of times, so + /// the same event can be overwritten in subsequent calls to this endpoint. Only a + /// single event with a given `event_id` will be considered the source of truth at + /// any given time. + /// + /// This is a powerful and audit-safe mechanism to retroactively update a + /// single event in cases where you need to: * update an event with new metadata as + /// you iterate on your pricing model * update an event based on the result of an + /// external API call (e.g. call to a payment gateway succeeded or failed) + /// + /// This amendment API is always audit-safe. The process will still retain the + /// original event, though it will be ignored for billing calculations. For auditing + /// and data fidelity purposes, Orb never overwrites or permanently deletes ingested + /// usage data. /// - /// ## Request validation * The `timestamp` of the new event must match - /// the `timestamp` of the existing event already ingested. As with ingestion, - /// all timestamps must be sent in ISO8601 format with UTC timezone offset. * - /// The `customer_id` or `external_customer_id` of the new event must match the - /// `customer_id` or `external_customer_id` of the existing event already ingested. - /// Exactly one of `customer_id` and `external_customer_id` should be specified, - /// and similar to ingestion, the ID must identify a Customer resource within - /// Orb. Unlike ingestion, for event amendment, we strictly enforce that the + /// ## Request validation * The `timestamp` of the new event must match the + /// `timestamp` of the existing event already ingested. As with ingestion, all + /// timestamps must be sent in ISO8601 format with UTC timezone offset. * The + /// `customer_id` or `external_customer_id` of the new event must match the + /// `customer_id` or `external_customer_id` of the existing event already + /// ingested. Exactly one of `customer_id` and `external_customer_id` should be + /// specified, and similar to ingestion, the ID must identify a Customer resource + /// within Orb. Unlike ingestion, for event amendment, we strictly enforce that the /// Customer must be in the Orb system, even during the initial integration - /// period. We do not allow updating the `Customer` an event is associated - /// with. * Orb does not accept an `idempotency_key` with the event in this endpoint, - /// since this request is by design idempotent. On retryable errors, you should - /// retry the request and assume the amendment operation has not succeeded until - /// receipt of a 2xx. * The event's `timestamp` must fall within the customer's - /// current subscription's billing period, or within the grace period of the - /// customer's current subscription's 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. + /// period. We do not allow updating the `Customer` an event is associated with. * + /// Orb does not accept an `idempotency_key` with the event in this endpoint, since + /// this request is by design idempotent. On retryable errors, you should retry + /// the request and assume the amendment operation has not succeeded until receipt + /// of a 2xx. * The event's `timestamp` must fall within the customer's current + /// subscription's billing period, or within the grace period of the customer's + /// current subscription's 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. /// Task Update( EventUpdateParams parameters, @@ -88,39 +92,39 @@ Task Update( /// This endpoint is used to deprecate a single usage event with a given `event_id`. /// `event_id` refers to the `idempotency_key` passed in during ingestion. /// - /// This endpoint will mark the existing event as ignored. Note that if - /// you attempt to re-ingest an event with the same `event_id` as a deprecated - /// event, Orb will return an error. + /// This endpoint will mark the existing event as ignored. Note that if you + /// attempt to re-ingest an event with the same `event_id` as a deprecated event, + /// Orb will return an error. /// - /// This is a powerful and audit-safe mechanism to retroactively deprecate - /// a single event in cases where you need to: * no longer bill for an event - /// that was improperly reported * no longer bill for an event based on the result - /// of an external API call (e.g. call to a payment gateway failed and the user - /// should not be billed) + /// This is a powerful and audit-safe mechanism to retroactively deprecate a + /// single event in cases where you need to: * no longer bill for an event that was + /// improperly reported * no longer bill for an event based on the result of an + /// external API call (e.g. call to a payment gateway failed and the user should + /// not be billed) /// - /// If you want to only change specific properties of an event, but keep - /// the event as part of the billing calculation, use the [Amend event](amend-event) + /// If you want to only change specific properties of an event, but keep the + /// event as part of the billing calculation, use the [Amend event](amend-event) /// endpoint instead. /// - /// This API is always audit-safe. The process will still retain the deprecated - /// event, though it will be ignored for billing calculations. For auditing and - /// data fidelity purposes, Orb never overwrites or permanently deletes ingested - /// usage data. + /// This API is always audit-safe. The process will still retain the + /// deprecated event, though it will be ignored for billing calculations. For + /// auditing and data fidelity purposes, Orb never overwrites or permanently deletes + /// ingested usage data. /// - /// ## Request validation * Orb does not accept an `idempotency_key` with - /// the event in this endpoint, since this request is by design idempotent. - /// On retryable errors, you should retry the request and assume the deprecation + /// ## Request validation * Orb does not accept an `idempotency_key` with the + /// event in this endpoint, since this request is by design idempotent. On + /// retryable errors, you should retry the request and assume the deprecation /// operation has not succeeded until receipt of a 2xx. * The event's `timestamp` - /// must fall within the customer's current subscription's billing period, or - /// within the grace period of the customer's current subscription's previous - /// billing period. Orb does not allow deprecating events for billing periods - /// that have already invoiced customers. * The `customer_id` or the `external_customer_id` - /// of the original event ingestion request must identify a Customer resource - /// within Orb, even if this event was ingested during the initial integration - /// period. We do not allow deprecating 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. + /// must fall within the customer's current subscription's billing period, or within + /// the grace period of the customer's current subscription's previous billing + /// period. Orb does not allow deprecating events for billing periods that have + /// already invoiced customers. * The `customer_id` or the `external_customer_id` of + /// the original event ingestion request must identify a Customer resource within + /// Orb, even if this event was ingested during the initial integration period. We + /// do not allow deprecating 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. /// Task Deprecate( EventDeprecateParams parameters, @@ -137,9 +141,9 @@ Task Deprecate( /// /// Orb's event ingestion model and API is designed around two core principles: /// - /// 1. **Data fidelity**: The accuracy of your billing model depends on - /// a robust foundation of events. Orb's API protocol encourages usage patterns - /// that ensure that your data is consistently complete and correct. 2. **Fast + /// 1. **Data fidelity**: The accuracy of your billing model depends on a + /// robust foundation of events. Orb's API protocol encourages usage patterns that + /// ensure that your data is consistently complete and correct. 2. **Fast /// integration**: Sending events into Orb requires no tedious setup steps or /// explicit field schema for your event shape, making it instant to start streaming /// in usage in real-time. @@ -150,45 +154,46 @@ Task Deprecate( /// and are simple at their core: /// /// ```ts { // customer_id and external_customer_id are used to // - /// attribute usage to a given Customer. Exactly one of these // should be specified - /// in a given ingestion event. + /// attribute usage to a given Customer. Exactly one of these // should be + /// specified in a given ingestion event. /// - /// // `customer_id` is the Orb generated identifier for the Customer, - /// // which is returned from the Create customer API call. customer_id: string, + /// // `customer_id` is the Orb generated identifier for the Customer, // + /// which is returned from the Create customer API call. customer_id: string, /// /// // external_customer_id is an alternate identifier which is associated - /// // with a Customer at creation time. This is treated as an alias for // + /// // with a Customer at creation time. This is treated as an alias for // /// customer_id, and is usually set to an identifier native to your system. - /// external_customer_id: string, + /// external_customer_id: string, /// - /// // A string name identifying the event, usually a usage // action. - /// By convention, this should not contain any whitespace. event_name: string, + /// // A string name identifying the event, usually a usage // action. By + /// convention, this should not contain any whitespace. event_name: string, /// /// // An ISO 8601 format date with no timezone offset. // This should - /// represent the time that usage occurred // and is important to attribute - /// usage to a given // billing period. See the notes below on determining - /// the timestamp. // e.g. 2020-12-09T16:09:53Z timestamp: string, + /// represent the time that usage occurred // and is important to attribute usage + /// to a given // billing period. See the notes below on determining the + /// timestamp. // e.g. 2020-12-09T16:09:53Z timestamp: string, /// - /// // A unique value, generated by the client, that is // used to de-duplicate - /// events. // Exactly one event with a given // idempotency key will be ingested, - /// which allows for // safe request retries. idempotency_key: string + /// // A unique value, generated by the client, that is // used to + /// de-duplicate events. // Exactly one event with a given // idempotency key + /// will be ingested, which allows for // safe request retries. idempotency_key: + /// string /// /// // Optional custom metadata to attach to the event. // This might /// include a numeric value used for aggregation, // or a string/boolean value /// used for filtering. // The schema of this dictionary need not be pre-declared, - /// and // properties can be added at any time. properties: { [key: string]?: - /// string | number | boolean, }, } ``` + /// and // properties can be added at any time. properties: { [key: + /// string]?: string | number | boolean, }, } ``` /// /// ## Required fields Because events streamed to Orb are meant to be as /// flexible as possible, there are only a few required fields in every event. /// - /// - We recommend that `idempotency_key` are unique strings that you generated - /// with V4 UUIDs, but only require that they uniquely identify an event (i.e. - /// don’t collide). - The `timestamp` field in the event body will be used to - /// determine which billable period a given event falls into. For example, with - /// a monthly billing cycle starting from the first of December, Orb will calculate - /// metrics based on events that fall into the range `12-01 00:00:00 <= timestamp - /// < 01-01 00:00:00`. + /// - We recommend that `idempotency_key` are unique strings that you + /// generated with V4 UUIDs, but only require that they uniquely identify an event + /// (i.e. don’t collide). - The `timestamp` field in the event body will be used to + /// determine which billable period a given event falls into. For example, with a + /// monthly billing cycle starting from the first of December, Orb will calculate + /// metrics based on events that fall into the range `12-01 00:00:00 <= timestamp < + /// 01-01 00:00:00`. /// /// ## Logging metadata /// @@ -198,110 +203,111 @@ Task Deprecate( /// /// This dictionary can be helpful for a wide variety of use cases: /// - /// - Numeric properties on events like `compute_time_ms` can later be - /// inputs to our flexible query engine to determine usage. - Logging a region - /// or cluster with each event can help you provide customers more granular visibility - /// into their usage. - If you are using matrix pricing and matching a matrix - /// price key with a property, you should ensure the value for that property is - /// sent as a string. + /// - Numeric properties on events like `compute_time_ms` can later be inputs + /// to our flexible query engine to determine usage. - Logging a region or cluster + /// with each event can help you provide customers more granular visibility into + /// their usage. - If you are using matrix pricing and matching a matrix price key + /// with a property, you should ensure the value for that property is sent as a + /// string. /// - /// We encourage logging this metadata with an eye towards future use cases - /// to ensure full coverage for historical data. The datatype of the value in - /// the properties dictionary is important for metric creation from an event - /// source. Values that you wish to numerically aggregate should be of numeric - /// type in the event. + /// We encourage logging this metadata with an eye towards future use cases to + /// ensure full coverage for historical data. The datatype of the value in the + /// properties dictionary is important for metric creation from an event source. + /// Values that you wish to numerically aggregate should be of numeric type in the + /// event. /// - /// ## Determining event timestamp For cases where usage is being reported - /// in real time as it is occurring, timestamp should correspond to the time - /// that usage occurred. + /// ## Determining event timestamp For cases where usage is being reported in + /// real time as it is occurring, timestamp should correspond to the time that usage + /// occurred. /// /// In cases where usage is reported in aggregate for a historical timeframe /// at a regular interval, we recommend setting the event `timestamp` to the /// midpoint of the interval. As an example, if you have an hourly reporter that /// sends data once an hour for the previous hour of usage, setting the `timestamp` - /// to the half-hour mark will ensure that the usage is counted within the correct period. + /// to the half-hour mark will ensure that the usage is counted within the correct + /// period. /// - /// Note that other time-related fields (e.g. time elapsed) can be added - /// to the properties dictionary as necessary. + /// Note that other time-related fields (e.g. time elapsed) can be added to + /// the properties dictionary as necessary. /// /// In cases where usage is reported in aggregate for a historical timeframe, - /// the timestamp must be within the grace period set for your account. Events - /// with `timestamp < current_time - grace_period` will not be accepted as a valid - /// event, and will throw validation errors. Enforcing the grace period enables - /// Orb to accurately map usage to the correct billing cycle and ensure that - /// all usage is billed for in the corresponding billing period. + /// the timestamp must be within the grace period set for your account. Events with + /// `timestamp < current_time - grace_period` will not be accepted as a valid event, + /// and will throw validation errors. Enforcing the grace period enables Orb to + /// accurately map usage to the correct billing cycle and ensure that all usage is + /// billed for in the corresponding billing period. /// - /// In general, Orb does not expect events with future dated timestamps. - /// In cases where the timestamp is at least 24 hours ahead of the current time, - /// the event will not be accepted as a valid event, and will throw validation errors. + /// In general, Orb does not expect events with future dated timestamps. In + /// cases where the timestamp is at least 24 hours ahead of the current time, the + /// event will not be accepted as a valid event, and will throw validation errors. /// /// ## Event validation /// /// Orb’s validation ensures that you recognize errors in your events as - /// quickly as possible, and the API provides informative error messages to help - /// you fix problems quickly. + /// quickly as possible, and the API provides informative error messages to help you + /// fix problems quickly. /// /// We validate the following: /// /// - Exactly one of `customer_id` and `external_customer_id` should be /// specified. - If the `customer_id` is specified, the customer in Orb must exist. - /// - If the `external_customer_id` is specified, the customer in Orb does not - /// need to exist. Events will be attributed to any future customers with the - /// `external_customer_id` on subscription creation. - `timestamp` must conform - /// to ISO 8601 and represent a timestamp at most 1 hour in the future. This - /// timestamp should be sent in UTC timezone (no timezone offset). + /// - If the `external_customer_id` is specified, the customer in Orb does not need + /// to exist. Events will be attributed to any future customers with the + /// `external_customer_id` on subscription creation. - `timestamp` must conform to + /// ISO 8601 and represent a timestamp at most 1 hour in the future. This timestamp + /// should be sent in UTC timezone (no timezone offset). /// /// ## Idempotency and retry semantics /// - /// Orb's idempotency guarantees allow you to implement safe retry logic - /// in the event of network or machine failures, ensuring data fidelity. Each - /// event in the request payload is associated with an idempotency key, and Orb - /// guarantees that a single idempotency key will be successfully ingested at - /// most once. Note that when Orb encounters events with duplicate idempotency - /// keys and differing event bodies in a batch of events, the entire batch will - /// be rejected. - /// - /// - Successful responses return a 200 HTTP status code. The response contains - /// information about previously processed events. - Requests that return a `4xx` - /// HTTP status code indicate a payload error and contain at least one event - /// with a validation failure. An event with a validation failure can be re-sent - /// to the ingestion endpoint (after the payload is fixed) with the original idempotency - /// key since that key is not marked as processed. - Requests that return a `5xx` - /// HTTP status code indicate a server-side failure. These requests should be - /// retried in their entirety. + /// Orb's idempotency guarantees allow you to implement safe retry logic in + /// the event of network or machine failures, ensuring data fidelity. Each event in + /// the request payload is associated with an idempotency key, and Orb guarantees + /// that a single idempotency key will be successfully ingested at most once. Note + /// that when Orb encounters events with duplicate idempotency keys and differing + /// event bodies in a batch of events, the entire batch will be rejected. + /// + /// - Successful responses return a 200 HTTP status code. The response + /// contains information about previously processed events. - Requests that return a + /// `4xx` HTTP status code indicate a payload error and contain at least one event + /// with a validation failure. An event with a validation failure can be re-sent to + /// the ingestion endpoint (after the payload is fixed) with the original + /// idempotency key since that key is not marked as processed. - Requests that + /// return a `5xx` HTTP status code indicate a server-side failure. These requests + /// should be retried in their entirety. /// /// ## API usage and limits The ingestion API is designed made for real-time /// streaming ingestion and architected for high throughput. Even if events are - /// later deemed unnecessary or filtered out, we encourage you to log them to - /// Orb if they may be relevant to billing calculations in the future. + /// later deemed unnecessary or filtered out, we encourage you to log them to Orb if + /// they may be relevant to billing calculations in the future. /// - /// To take advantage of the real-time features of the Orb platform and - /// avoid any chance of dropped events by producers, we recommend reporting events - /// to Orb frequently. Optionally, events can also be briefly aggregated at the - /// source, as this API accepts an array of event bodies. + /// To take advantage of the real-time features of the Orb platform and avoid + /// any chance of dropped events by producers, we recommend reporting events to Orb + /// frequently. Optionally, events can also be briefly aggregated at the source, as + /// this API accepts an array of event bodies. /// /// Orb does not currently enforce a hard rate-limit for API usage or a /// maximum request payload size, but please give us a heads up if you’re changing /// either of these factors by an order of magnitude from initial setup. /// /// ## Testing in debug mode The ingestion API supports a debug mode, which - /// returns additional verbose output to indicate which event idempotency keys - /// were newly ingested or duplicates from previous requests. To enable this - /// mode, mark `debug=true` as a query parameter. + /// returns additional verbose output to indicate which event idempotency keys were + /// newly ingested or duplicates from previous requests. To enable this mode, mark + /// `debug=true` as a query parameter. /// - /// If `debug=true` is not specified, the response will only contain `validation_failed`. - /// Orb will still honor the idempotency guarantees set [here](/events-and-metrics/event-ingestion#event-volume-and-concurrency) - /// in all cases. + /// If `debug=true` is not specified, the response will only contain + /// `validation_failed`. Orb will still honor the idempotency guarantees set + /// [here](/events-and-metrics/event-ingestion#event-volume-and-concurrency) in all + /// cases. /// - /// We strongly recommend that you only use debug mode as part of testing - /// your initial Orb integration. Once you're ready to switch to production, - /// disable debug mode to take advantage of improved performance and maximal throughput. + /// We strongly recommend that you only use debug mode as part of testing your + /// initial Orb integration. Once you're ready to switch to production, disable + /// debug mode to take advantage of improved performance and maximal throughput. /// /// #### Example: ingestion response with `debug=true` /// /// ```json { "debug": { "duplicate": [], "ingested": [ - /// "B7E83HDMfJPAunXW", "SJs5DQJ3TnwSqEZE", "8SivfDsNKwCeAXim" - /// ] }, "validation_failed": [] } ``` + /// "B7E83HDMfJPAunXW", "SJs5DQJ3TnwSqEZE", "8SivfDsNKwCeAXim" ] + /// }, "validation_failed": [] } ``` /// /// #### Example: ingestion response with `debug=false` /// @@ -317,13 +323,13 @@ Task Ingest( /// list format](/api-reference/pagination). /// /// Note that this is a `POST` endpoint rather than a `GET` endpoint because - /// it employs a JSON body for search criteria rather than query parameters, allowing - /// for a more flexible search syntax. + /// it employs a JSON body for search criteria rather than query parameters, + /// allowing for a more flexible search syntax. /// /// Note that a search criteria _must_ be specified. Currently, Orb supports /// the following criteria: - `event_ids`: This is an explicit array of IDs to - /// filter by. Note that an event's ID is the `idempotency_key` that was originally - /// used for ingestion. + /// filter by. Note that an event's ID is the `idempotency_key` that was + /// originally used for ingestion. /// /// By default, Orb will not throw a `404` if no events matched, Orb will /// return an empty array for `data` instead. @@ -352,7 +358,7 @@ public interface IEventServiceWithRawResponse IVolumeServiceWithRawResponse Volume { get; } /// - /// Returns a raw HTTP response for `put /events/{event_id}`, but is otherwise the + /// Returns a raw HTTP response for put /events/{event_id}, but is otherwise the /// same as . /// Task> Update( @@ -368,7 +374,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `put /events/{event_id}/deprecate`, but is otherwise the + /// Returns a raw HTTP response for put /events/{event_id}/deprecate, but is otherwise the /// same as . /// Task> Deprecate( @@ -384,7 +390,7 @@ Task> Deprecate( ); /// - /// Returns a raw HTTP response for `post /ingest`, but is otherwise the + /// Returns a raw HTTP response for post /ingest, but is otherwise the /// same as . /// Task> Ingest( @@ -393,7 +399,7 @@ Task> Ingest( ); /// - /// Returns a raw HTTP response for `post /events/search`, but is otherwise the + /// Returns a raw HTTP response for post /events/search, but is otherwise the /// same as . /// Task> Search( diff --git a/src/Orb/Services/IInvoiceLineItemService.cs b/src/Orb/Services/IInvoiceLineItemService.cs index d4cd93aa6..55c11e4a2 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 { @@ -27,17 +33,17 @@ public interface IInvoiceLineItemService IInvoiceLineItemService WithOptions(Func modifier); /// - /// This creates a one-off fixed fee invoice line item on an Invoice. This can - /// only be done for invoices that are in a `draft` status. + /// This creates a one-off fixed fee invoice line item on an Invoice. This can only + /// be done for invoices that are in a `draft` status. /// - /// The behavior depends on which parameters are provided: - If `item_id` - /// is provided without `name`: The item is looked up by ID, and the item's name - /// is used for the line item. - If `name` is provided without `item_id`: An - /// item with the given name is searched for in the account. If found, that - /// item is used. If not found, a new item is created with that name. The new - /// item's name is used 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). + /// The behavior depends on which parameters are provided: - If `item_id` is + /// provided without `name`: The item is looked up by ID, and the item's name is + /// used for the line item. - If `name` is provided without `item_id`: An item with + /// the given name is searched for in the account. If found, that item is used. If + /// not found, a new item is created with that name. The new item's name is used + /// 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). /// Task Create( InvoiceLineItemCreateParams parameters, @@ -59,7 +65,7 @@ public interface IInvoiceLineItemServiceWithRawResponse IInvoiceLineItemServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /invoice_line_items`, but is otherwise the + /// Returns a raw HTTP response for post /invoice_line_items, but is otherwise the /// same as . /// Task> Create( diff --git a/src/Orb/Services/IInvoiceService.cs b/src/Orb/Services/IInvoiceService.cs index 36d477592..ae638413d 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, @@ -57,14 +64,16 @@ Task Update( ); /// - /// This endpoint returns a list of all [`Invoice`](/core-concepts#invoice)s - /// for an account in a list format. + /// This endpoint returns a list of all [`Invoice`](/core-concepts#invoice)s for an + /// account in a list format. /// /// The list of invoices is ordered starting from the most recently issued - /// invoice date. The response also includes [`pagination_metadata`](/api-reference/pagination), - /// which lets the caller retrieve the next page of results if they exist. + /// invoice date. The response also includes + /// [`pagination_metadata`](/api-reference/pagination), which lets the caller + /// retrieve the next page of results if they exist. /// - /// By default, this only returns invoices that are `issued`, `paid`, or `synced`. + /// By default, this only returns invoices that are `issued`, `paid`, or + /// `synced`. /// /// 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 @@ -78,8 +87,9 @@ Task List( /// /// This endpoint deletes an invoice line item from a draft invoice. /// - /// 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. + /// 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. /// Task DeleteLineItem( InvoiceDeleteLineItemParams parameters, @@ -94,8 +104,8 @@ Task DeleteLineItem( ); /// - /// This endpoint is used to fetch an [`Invoice`](/core-concepts#invoice) given - /// an identifier. + /// This endpoint is used to fetch an [`Invoice`](/core-concepts#invoice) given an + /// identifier. /// Task Fetch( InvoiceFetchParams parameters, @@ -110,8 +120,9 @@ Task Fetch( ); /// - /// This endpoint can be used to fetch the upcoming [invoice](/core-concepts#invoice) - /// for the current billing period given a subscription. + /// This endpoint can be used to fetch the upcoming + /// [invoice](/core-concepts#invoice) for the current billing period given a + /// subscription. /// Task FetchUpcoming( InvoiceFetchUpcomingParams parameters, @@ -120,8 +131,8 @@ Task FetchUpcoming( /// /// 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 + /// 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). @@ -139,17 +150,42 @@ Task Issue( ); /// - /// This is a lighter-weight endpoint that returns a list of all [`Invoice`](/core-concepts#invoice) - /// summaries for an account in a list format. + /// 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. /// /// These invoice summaries do not include line item details, minimums, /// maximums, and discounts, making this endpoint more efficient. /// /// The list of invoices is ordered starting from the most recently issued - /// invoice date. The response also includes [`pagination_metadata`](/api-reference/pagination), - /// which lets the caller retrieve the next page of results if they exist. + /// invoice date. The response also includes + /// [`pagination_metadata`](/api-reference/pagination), which lets the caller + /// retrieve the next page of results if they exist. /// - /// By default, this only returns invoices that are `issued`, `paid`, or `synced`. + /// By default, this only returns invoices that are `issued`, `paid`, or + /// `synced`. /// /// 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 @@ -177,15 +213,17 @@ Task MarkPaid( ); /// - /// 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". + /// This endpoint collects payment for an invoice. By default, it uses the + /// customer's default payment method. Optionally, a shared payment token (SPT) can + /// be provided to pay using agent-granted credentials instead. This action can only + /// be taken on invoices with status "issued". /// Task Pay(InvoicePayParams parameters, CancellationToken cancellationToken = default); /// Task Pay( string invoiceID, - InvoicePayParams? parameters = null, + InvoicePayParams parameters, CancellationToken cancellationToken = default ); @@ -194,13 +232,13 @@ Task Pay( /// can only be done to invoices that are in the `issued` status. /// /// If the associated invoice has used the customer balance to change the - /// amount due, the customer balance operation will be reverted. For example, - /// if the invoice used \$10 of customer balance, that amount will be added back - /// to the customer balance upon voiding. + /// amount due, the customer balance operation will be reverted. For example, if the + /// invoice used \$10 of customer balance, that amount will be added back to the + /// customer balance upon voiding. /// - /// 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. + /// 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. /// Task Void(InvoiceVoidParams parameters, CancellationToken cancellationToken = default); @@ -226,7 +264,7 @@ public interface IInvoiceServiceWithRawResponse IInvoiceServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /invoices`, but is otherwise the + /// Returns a raw HTTP response for post /invoices, but is otherwise the /// same as . /// Task> Create( @@ -235,7 +273,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `put /invoices/{invoice_id}`, but is otherwise the + /// Returns a raw HTTP response for put /invoices/{invoice_id}, but is otherwise the /// same as . /// Task> Update( @@ -251,7 +289,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `get /invoices`, but is otherwise the + /// Returns a raw HTTP response for get /invoices, but is otherwise the /// same as . /// Task> List( @@ -260,7 +298,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `delete /invoices/{invoice_id}/invoice_line_items/{line_item_id}`, but is otherwise the + /// Returns a raw HTTP response for delete /invoices/{invoice_id}/invoice_line_items/{line_item_id}, but is otherwise the /// same as . /// Task DeleteLineItem( @@ -276,7 +314,7 @@ Task DeleteLineItem( ); /// - /// Returns a raw HTTP response for `get /invoices/{invoice_id}`, but is otherwise the + /// Returns a raw HTTP response for get /invoices/{invoice_id}, but is otherwise the /// same as . /// Task> Fetch( @@ -292,7 +330,7 @@ Task> Fetch( ); /// - /// Returns a raw HTTP response for `get /invoices/upcoming`, but is otherwise the + /// Returns a raw HTTP response for get /invoices/upcoming, but is otherwise the /// same as . /// Task> FetchUpcoming( @@ -301,7 +339,7 @@ Task> FetchUpcoming( ); /// - /// Returns a raw HTTP response for `post /invoices/{invoice_id}/issue`, but is otherwise the + /// Returns a raw HTTP response for post /invoices/{invoice_id}/issue, but is otherwise the /// same as . /// Task> Issue( @@ -317,7 +355,23 @@ Task> Issue( ); /// - /// Returns a raw HTTP response for `get /invoices/summary`, but is otherwise the + /// 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 . /// Task> ListSummary( @@ -326,7 +380,7 @@ Task> ListSummary( ); /// - /// Returns a raw HTTP response for `post /invoices/{invoice_id}/mark_paid`, but is otherwise the + /// Returns a raw HTTP response for post /invoices/{invoice_id}/mark_paid, but is otherwise the /// same as . /// Task> MarkPaid( @@ -342,7 +396,7 @@ Task> MarkPaid( ); /// - /// Returns a raw HTTP response for `post /invoices/{invoice_id}/pay`, but is otherwise the + /// Returns a raw HTTP response for post /invoices/{invoice_id}/pay, but is otherwise the /// same as . /// Task> Pay( @@ -353,12 +407,12 @@ Task> Pay( /// Task> Pay( string invoiceID, - InvoicePayParams? parameters = null, + InvoicePayParams parameters, CancellationToken cancellationToken = default ); /// - /// Returns a raw HTTP response for `post /invoices/{invoice_id}/void`, but is otherwise the + /// Returns a raw HTTP response for post /invoices/{invoice_id}/void, but is otherwise the /// same as . /// Task> Void( diff --git a/src/Orb/Services/IItemService.cs b/src/Orb/Services/IItemService.cs index 12955b7fb..fcd52e851 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 { @@ -91,7 +95,7 @@ public interface IItemServiceWithRawResponse IItemServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /items`, but is otherwise the + /// Returns a raw HTTP response for post /items, but is otherwise the /// same as . /// Task> Create( @@ -100,7 +104,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `put /items/{item_id}`, but is otherwise the + /// Returns a raw HTTP response for put /items/{item_id}, but is otherwise the /// same as . /// Task> Update( @@ -116,7 +120,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `get /items`, but is otherwise the + /// Returns a raw HTTP response for get /items, but is otherwise the /// same as . /// Task> List( @@ -125,7 +129,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `post /items/{item_id}/archive`, but is otherwise the + /// Returns a raw HTTP response for post /items/{item_id}/archive, but is otherwise the /// same as . /// Task> Archive( @@ -141,7 +145,7 @@ Task> Archive( ); /// - /// Returns a raw HTTP response for `get /items/{item_id}`, but is otherwise the + /// Returns a raw HTTP response for get /items/{item_id}, but is otherwise the /// same as . /// Task> Fetch( diff --git a/src/Orb/Services/ILicenseService.cs b/src/Orb/Services/ILicenseService.cs new file mode 100644 index 000000000..77e086490 --- /dev/null +++ b/src/Orb/Services/ILicenseService.cs @@ -0,0 +1,188 @@ +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..e09d57f28 --- /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..6fae3aa5b 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 { @@ -27,9 +31,9 @@ public interface IMetricService IMetricService WithOptions(Func modifier); /// - /// 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. + /// 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. /// Task Create( MetricCreateParams parameters, @@ -37,9 +41,9 @@ Task Create( ); /// - /// 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. + /// 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. /// Task Update( MetricUpdateParams parameters, @@ -54,9 +58,9 @@ Task Update( ); /// - /// 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. + /// 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. /// Task List( MetricListParams? parameters = null, @@ -94,7 +98,7 @@ public interface IMetricServiceWithRawResponse IMetricServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /metrics`, but is otherwise the + /// Returns a raw HTTP response for post /metrics, but is otherwise the /// same as . /// Task> Create( @@ -103,7 +107,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `put /metrics/{metric_id}`, but is otherwise the + /// Returns a raw HTTP response for put /metrics/{metric_id}, but is otherwise the /// same as . /// Task> Update( @@ -119,7 +123,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `get /metrics`, but is otherwise the + /// Returns a raw HTTP response for get /metrics, but is otherwise the /// same as . /// Task> List( @@ -128,7 +132,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `get /metrics/{metric_id}`, but is otherwise the + /// Returns a raw HTTP response for get /metrics/{metric_id}, but is otherwise the /// same as . /// Task> Fetch( diff --git a/src/Orb/Services/IPlanService.cs b/src/Orb/Services/IPlanService.cs index e7eac2227..8f7f8f49e 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 { @@ -37,8 +41,8 @@ public interface IPlanService Task Create(PlanCreateParams parameters, CancellationToken cancellationToken = default); /// - /// This endpoint can be used to update the `external_plan_id`, and `metadata` - /// of an existing plan. + /// This endpoint can be used to update the `external_plan_id`, and `metadata` of an + /// existing plan. /// /// Other fields on a plan are currently immutable. /// @@ -52,10 +56,11 @@ Task Update( ); /// - /// This endpoint returns a list of all [plans](/core-concepts#plan-and-price) - /// for 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. + /// This endpoint returns a list of all [plans](/core-concepts#plan-and-price) for + /// 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. /// Task List( PlanListParams? parameters = null, @@ -64,15 +69,15 @@ Task List( /// /// This endpoint is used to fetch [plan](/core-concepts#plan-and-price) details - /// given a plan identifier. It returns information about the prices included - /// in the plan and their configuration, as well as the product that the plan - /// is attached to. + /// given a plan identifier. It returns information about the prices included in the + /// plan and their configuration, as well as the product that the plan is attached + /// to. /// - /// ## Serialized prices Orb supports a few different pricing models out - /// of the box. Each of these models is serialized differently in a given [Price](/core-concepts#plan-and-price) - /// 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). + /// ## Serialized prices Orb supports a few different pricing models out of + /// the box. Each of these models is serialized differently in a given + /// [Price](/core-concepts#plan-and-price) 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). /// /// ## Phases Orb supports plan phases, also known as contract ramps. For /// plans with phases, the serialized prices refer to all prices across all phases. @@ -105,7 +110,7 @@ public interface IPlanServiceWithRawResponse IMigrationServiceWithRawResponse Migrations { get; } /// - /// Returns a raw HTTP response for `post /plans`, but is otherwise the + /// Returns a raw HTTP response for post /plans, but is otherwise the /// same as . /// Task> Create( @@ -114,7 +119,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `put /plans/{plan_id}`, but is otherwise the + /// Returns a raw HTTP response for put /plans/{plan_id}, but is otherwise the /// same as . /// Task> Update( @@ -130,7 +135,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `get /plans`, but is otherwise the + /// Returns a raw HTTP response for get /plans, but is otherwise the /// same as . /// Task> List( @@ -139,7 +144,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `get /plans/{plan_id}`, but is otherwise the + /// Returns a raw HTTP response for get /plans/{plan_id}, but is otherwise the /// same as . /// Task> Fetch( diff --git a/src/Orb/Services/IPriceService.cs b/src/Orb/Services/IPriceService.cs index 0cf829df2..222721a89 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 { @@ -32,9 +42,9 @@ public interface IPriceService /// /// This endpoint is used to create a [price](/product-catalog/price-configuration). - /// A price created using this endpoint is always an add-on, meaning that it's - /// not associated with a specific plan and can instead be individually added - /// to subscriptions, including subscriptions on different plans. + /// A price created using this endpoint is always an add-on, meaning that it's not + /// associated with a specific plan and can instead be individually added to + /// subscriptions, including subscriptions on different plans. /// /// An `external_price_id` can be optionally specified as an alias to allow /// ergonomic interaction with prices in the Orb API. @@ -48,9 +58,9 @@ public interface IPriceService ); /// - /// 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. + /// 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. /// Task Update( PriceUpdateParams parameters, @@ -65,7 +75,8 @@ public interface IPriceService ); /// - /// This endpoint is used to list all add-on prices created using the [price creation endpoint](/api-reference/price/create-price). + /// This endpoint is used to list all add-on prices created using the [price + /// creation endpoint](/api-reference/price/create-price). /// Task List( PriceListParams? parameters = null, @@ -85,18 +96,19 @@ Task List( /// 1. Showing detailed usage and costs to the end customer. 2. Auditing /// subtotals on invoice line items. /// - /// For these workflows, the expressiveness of computed properties in both - /// the filters and grouping is critical. For example, if you'd like to show your + /// For these workflows, the expressiveness of computed properties in both the + /// filters and grouping is critical. For example, if you'd like to show your /// customer their usage grouped by hour and another property, you can do so with - /// the following `grouping_keys`: `["hour_floor_timestamp_millis(timestamp_millis)", - /// "my_property"]`. If you'd like to examine a customer's usage for a specific - /// property value, you can do so with the following `filter`: `my_property = - /// 'foo' AND my_other_property = 'bar'`. + /// the following `grouping_keys`: + /// `["hour_floor_timestamp_millis(timestamp_millis)", "my_property"]`. If you'd + /// like to examine a customer's usage for a specific property value, you can do so + /// with the following `filter`: `my_property = 'foo' AND my_other_property = + /// 'bar'`. /// - /// By default, the start of the time range must be no more than 100 days - /// ago 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. + /// By default, the start of the time range must be no more than 100 days ago + /// 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. /// Task Evaluate( PriceEvaluateParams parameters, @@ -113,31 +125,34 @@ Task Evaluate( /// /// This endpoint is used to evaluate the output of price(s) for a given customer /// and time range over ingested events. It enables filtering and grouping the - /// output using [computed properties](/extensibility/advanced-metrics#computed-properties), - /// supporting the following workflows: + /// output using [computed + /// properties](/extensibility/advanced-metrics#computed-properties), supporting the + /// following workflows: /// /// 1. Showing detailed usage and costs to the end customer. 2. Auditing /// subtotals on invoice line items. /// - /// For these workflows, the expressiveness of computed properties in both - /// the filters and grouping is critical. For example, if you'd like to show your + /// For these workflows, the expressiveness of computed properties in both the + /// filters and grouping is critical. For example, if you'd like to show your /// customer their usage grouped by hour and another property, you can do so with - /// the following `grouping_keys`: `["hour_floor_timestamp_millis(timestamp_millis)", - /// "my_property"]`. If you'd like to examine a customer's usage for a specific - /// property value, you can do so with the following `filter`: `my_property = - /// 'foo' AND my_other_property = 'bar'`. + /// the following `grouping_keys`: + /// `["hour_floor_timestamp_millis(timestamp_millis)", "my_property"]`. If you'd + /// like to examine a customer's usage for a specific property value, you can do so + /// with the following `filter`: `my_property = 'foo' AND my_other_property = + /// 'bar'`. /// /// Prices may either reference existing prices in your Orb account or be - /// defined inline in the request body. Up to 100 prices can be evaluated in - /// a single request. + /// defined inline in the request body. Up to 100 prices can be evaluated in a + /// single request. /// /// Prices are evaluated on ingested events and the start of the time range /// must be no more than 100 days ago. To evaluate based off a set of provided - /// events, the [evaluate preview events](/api-reference/price/evaluate-preview-events) - /// endpoint can be used instead. + /// events, the [evaluate preview + /// events](/api-reference/price/evaluate-preview-events) endpoint can be used + /// instead. /// - /// Note that this is a POST endpoint rather than a GET endpoint because - /// it employs a JSON body rather than query parameters. + /// Note that this is a POST endpoint rather than a GET endpoint because it + /// employs a JSON body rather than query parameters. /// Task EvaluateMultiple( PriceEvaluateMultipleParams parameters, @@ -145,10 +160,11 @@ Task EvaluateMultiple( ); /// - /// This endpoint evaluates prices on preview events instead of actual usage, - /// making it ideal for building price calculators and cost estimation tools. - /// You can filter and group results using [computed properties](/extensibility/advanced-metrics#computed-properties) - /// to analyze pricing across different dimensions. + /// This endpoint evaluates prices on preview events instead of actual usage, making + /// it ideal for building price calculators and cost estimation tools. You can + /// filter and group results using [computed + /// properties](/extensibility/advanced-metrics#computed-properties) to analyze + /// pricing across different dimensions. /// /// Prices may either reference existing prices in your Orb account or be /// defined inline in the request body. The endpoint has the following limitations: @@ -156,10 +172,11 @@ Task EvaluateMultiple( /// events can be provided in a single request. /// /// A top-level customer_id is required to evaluate the preview events. - /// Additionally, all events without a customer_id will have the top-level customer_id added. + /// Additionally, all events without a customer_id will have the top-level + /// customer_id added. /// - /// Note that this is a POST endpoint rather than a GET endpoint because - /// it employs a JSON body rather than query parameters. + /// Note that this is a POST endpoint rather than a GET endpoint because it + /// employs a JSON body rather than query parameters. /// Task EvaluatePreviewEvents( PriceEvaluatePreviewEventsParams parameters, @@ -198,7 +215,7 @@ public interface IPriceServiceWithRawResponse IExternalPriceIDServiceWithRawResponse ExternalPriceID { get; } /// - /// Returns a raw HTTP response for `post /prices`, but is otherwise the + /// Returns a raw HTTP response for post /prices, but is otherwise the /// same as . /// Task> Create( @@ -207,7 +224,7 @@ public interface IPriceServiceWithRawResponse ); /// - /// Returns a raw HTTP response for `put /prices/{price_id}`, but is otherwise the + /// Returns a raw HTTP response for put /prices/{price_id}, but is otherwise the /// same as . /// Task> Update( @@ -223,7 +240,7 @@ public interface IPriceServiceWithRawResponse ); /// - /// Returns a raw HTTP response for `get /prices`, but is otherwise the + /// Returns a raw HTTP response for get /prices, but is otherwise the /// same as . /// Task> List( @@ -232,7 +249,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `post /prices/{price_id}/evaluate`, but is otherwise the + /// Returns a raw HTTP response for post /prices/{price_id}/evaluate, but is otherwise the /// same as . /// Task> Evaluate( @@ -248,7 +265,7 @@ Task> Evaluate( ); /// - /// Returns a raw HTTP response for `post /prices/evaluate`, but is otherwise the + /// Returns a raw HTTP response for post /prices/evaluate, but is otherwise the /// same as . /// Task> EvaluateMultiple( @@ -257,7 +274,7 @@ Task> EvaluateMultiple( ); /// - /// Returns a raw HTTP response for `post /prices/evaluate_preview_events`, but is otherwise the + /// Returns a raw HTTP response for post /prices/evaluate_preview_events, but is otherwise the /// same as . /// Task> EvaluatePreviewEvents( @@ -266,7 +283,7 @@ Task> EvaluatePreviewEvents( ); /// - /// Returns a raw HTTP response for `get /prices/{price_id}`, but is otherwise the + /// Returns a raw HTTP response for get /prices/{price_id}, but is otherwise the /// same as . /// Task> Fetch( diff --git a/src/Orb/Services/ISubscriptionChangeService.cs b/src/Orb/Services/ISubscriptionChangeService.cs index 0dc7efdb8..d802c87d7 100644 --- a/src/Orb/Services/ISubscriptionChangeService.cs +++ b/src/Orb/Services/ISubscriptionChangeService.cs @@ -29,11 +29,12 @@ public interface ISubscriptionChangeService /// /// This endpoint returns a subscription change given an identifier. /// - /// A subscription change is created by including `Create-Pending-Subscription-Change: - /// True` in the header of a subscription mutation API call (e.g. [create subscription + /// A subscription change is created by including + /// `Create-Pending-Subscription-Change: True` in the header of a subscription + /// mutation API call (e.g. [create subscription /// endpoint](/api-reference/subscription/create-subscription), [schedule plan - /// change endpoint](/api-reference/subscription/schedule-plan-change), ...). - /// The subscription change will be referenced by the `pending_subscription_change` + /// change endpoint](/api-reference/subscription/schedule-plan-change), ...). The + /// subscription change will be referenced by the `pending_subscription_change` /// field in the response. /// Task Retrieve( @@ -49,9 +50,9 @@ Task Retrieve( ); /// - /// 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. + /// 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. /// Task List( SubscriptionChangeListParams? parameters = null, @@ -59,9 +60,9 @@ Task List( ); /// - /// 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. + /// 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. /// Task Apply( SubscriptionChangeApplyParams parameters, @@ -76,9 +77,9 @@ Task Apply( ); /// - /// 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. + /// 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. /// Task Cancel( SubscriptionChangeCancelParams parameters, @@ -109,7 +110,7 @@ Func modifier ); /// - /// Returns a raw HTTP response for `get /subscription_changes/{subscription_change_id}`, but is otherwise the + /// Returns a raw HTTP response for get /subscription_changes/{subscription_change_id}, but is otherwise the /// same as . /// Task> Retrieve( @@ -125,7 +126,7 @@ Task> Retrieve( ); /// - /// Returns a raw HTTP response for `get /subscription_changes`, but is otherwise the + /// Returns a raw HTTP response for get /subscription_changes, but is otherwise the /// same as . /// Task> List( @@ -134,7 +135,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `post /subscription_changes/{subscription_change_id}/apply`, but is otherwise the + /// Returns a raw HTTP response for post /subscription_changes/{subscription_change_id}/apply, but is otherwise the /// same as . /// Task> Apply( @@ -150,7 +151,7 @@ Task> Apply( ); /// - /// Returns a raw HTTP response for `post /subscription_changes/{subscription_change_id}/cancel`, but is otherwise the + /// Returns a raw HTTP response for post /subscription_changes/{subscription_change_id}/cancel, but is otherwise the /// same as . /// Task> Cancel( diff --git a/src/Orb/Services/ISubscriptionService.cs b/src/Orb/Services/ISubscriptionService.cs index 66fca4fab..3ccf63e97 100644 --- a/src/Orb/Services/ISubscriptionService.cs +++ b/src/Orb/Services/ISubscriptionService.cs @@ -28,112 +28,119 @@ public interface ISubscriptionService ISubscriptionService WithOptions(Func modifier); /// - /// A subscription represents the purchase of a plan by a customer. The customer - /// is identified by either the `customer_id` or the `external_customer_id`, - /// and exactly one of these fields must be provided. + /// A subscription represents the purchase of a plan by a customer. The customer is + /// identified by either the `customer_id` or the `external_customer_id`, and + /// exactly one of these fields must be provided. /// - /// By default, subscriptions begin on the day that they're created and - /// renew automatically for each billing cycle at the cadence that's configured - /// in the plan definition. + /// By default, subscriptions begin on the day that they're created and renew + /// automatically for each billing cycle at the cadence that's configured in the + /// plan definition. /// - /// The default configuration for subscriptions in Orb is **In-advance billing** - /// and **Beginning of month alignment** (see [Subscription](/core-concepts##subscription) - /// for more details). + /// The default configuration for subscriptions in Orb is **In-advance + /// billing** and **Beginning of month alignment** (see + /// [Subscription](/core-concepts##subscription) for more details). /// /// In order to change the alignment behavior, Orb also supports billing - /// subscriptions on the day of the month they are created. If `align_billing_with_subscription_start_date - /// = true` is specified, subscriptions have billing cycles that are aligned - /// with their `start_date`. For example, a subscription that begins on January - /// 15th will have a billing cycle from January 15th to February 15th. Every - /// subsequent billing cycle will continue to start and invoice on the 15th. - /// - /// If the "day" value is greater than the number of days in the month, - /// the next billing cycle will start at the end of the month. For example, if - /// the start_date is January 31st, the next billing cycle will start on February 28th. - /// - /// If a customer was created with a currency, Orb only allows subscribing - /// the customer to a plan with a matching `invoicing_currency`. If the customer - /// does not have a currency set, on subscription creation, we set the customer's + /// subscriptions on the day of the month they are created. If + /// `align_billing_with_subscription_start_date = true` is specified, subscriptions + /// have billing cycles that are aligned with their `start_date`. For example, a + /// subscription that begins on January 15th will have a billing cycle from January + /// 15th to February 15th. Every subsequent billing cycle will continue to start and + /// invoice on the 15th. + /// + /// If the "day" value is greater than the number of days in the month, the + /// next billing cycle will start at the end of the month. For example, if the + /// start_date is January 31st, the next billing cycle will start on February 28th. + /// + /// If a customer was created with a currency, Orb only allows subscribing the + /// customer to a plan with a matching `invoicing_currency`. If the customer does + /// not have a currency set, on subscription creation, we set the customer's /// currency to be the `invoicing_currency` of the plan. /// /// ## Customize your customer's subscriptions /// - /// Prices and adjustments in a plan can be added, removed, or replaced - /// for the subscription being created. This is useful when a customer has prices - /// that differ from the default prices for a specific plan. + /// Prices and adjustments in a plan can be added, removed, or replaced for + /// the subscription being created. This is useful when a customer has prices that + /// differ from the default prices for a specific plan. /// - /// This feature is only available for accounts that have migrated - /// to Subscription Overrides Version 2. You can find your Subscription Overrides - /// Version at the bottom of your [Plans page](https://app.withorb.com/plans) + /// This feature is only available for accounts that have migrated to + /// Subscription Overrides Version 2. You can find your Subscription Overrides + /// Version at the bottom of your [Plans page](https://app.withorb.com/plans) + /// /// /// ### Adding Prices /// - /// To add prices, provide a list of objects with the key `add_prices`. - /// An object in the list must specify an existing add-on price with a `price_id` - /// or `external_price_id` field, or create a new add-on price by including an - /// object with the key `price`, identical to what would be used in the request - /// body for the [create price endpoint](/api-reference/price/create-price). - /// See the [Price resource](/product-catalog/price-configuration) for the specification - /// of different price model configurations possible in this object. + /// To add prices, provide a list of objects with the key `add_prices`. An + /// object in the list must specify an existing add-on price with a `price_id` or + /// `external_price_id` field, or create a new add-on price by including an object + /// with the key `price`, identical to what would be used in the request body for + /// the [create price endpoint](/api-reference/price/create-price). See the [Price + /// resource](/product-catalog/price-configuration) for the specification of + /// different price model configurations possible in this object. /// - /// If the plan has phases, each object in the list must include a number - /// with `plan_phase_order` key to indicate which phase the price should be added to. + /// If the plan has phases, each object in the list must include a number with + /// `plan_phase_order` key to indicate which phase the price should be added to. /// /// An object in the list can specify an optional `start_date` and optional /// `end_date`. This is equivalent to creating a price interval with the [add/edit - /// price intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). - /// If unspecified, the start or end date of the phase or subscription will be used. + /// price intervals + /// endpoint](/api-reference/price-interval/add-or-edit-price-intervals). If + /// unspecified, the start or end date of the phase or subscription will be used. /// - /// An object in the list can specify an optional `minimum_amount`, `maximum_amount`, - /// or `discounts`. This will create adjustments which apply only to this price. + /// An object in the list can specify an optional `minimum_amount`, + /// `maximum_amount`, or `discounts`. This will create adjustments which apply only + /// to this price. /// - /// Additionally, an object in the list can specify an optional `reference_id`. - /// This ID can be used to reference this price when [adding an adjustment](#adding-adjustments) - /// in the same API call. However the ID is _transient_ and cannot be used to - /// refer to the price in future API calls. + /// Additionally, an object in the list can specify an optional + /// `reference_id`. This ID can be used to reference this price when [adding an + /// adjustment](#adding-adjustments) in the same API call. However the ID is + /// _transient_ and cannot be used to refer to the price in future API calls. /// /// ### Removing Prices /// /// To remove prices, provide a list of objects with the key `remove_prices`. - /// An object in the list must specify a plan price with either a `price_id` - /// or `external_price_id` field. + /// An object in the list must specify a plan price with either a `price_id` or + /// `external_price_id` field. /// /// ### Replacing Prices /// - /// To replace prices, provide a list of objects with the key `replace_prices`. - /// An object in the list must specify a plan price to replace with the `replaces_price_id` - /// key, and it must specify a price to replace it with by either referencing - /// an existing add-on price with a `price_id` or `external_price_id` field, or - /// by creating a new add-on price by including an object with the key `price`, - /// identical to what would be used in the request body for the [create price - /// endpoint](/api-reference/price/create-price). See the [Price resource](/product-catalog/price-configuration) - /// for the specification of different price model configurations possible in - /// this object. + /// To replace prices, provide a list of objects with the key + /// `replace_prices`. An object in the list must specify a plan price to replace + /// with the `replaces_price_id` key, and it must specify a price to replace it with + /// by either referencing an existing add-on price with a `price_id` or + /// `external_price_id` field, or by creating a new add-on price by including an + /// object with the key `price`, identical to what would be used in the request body + /// for the [create price endpoint](/api-reference/price/create-price). See the + /// [Price resource](/product-catalog/price-configuration) for the specification of + /// different price model configurations possible in this object. /// /// For fixed fees, an object in the list can supply a `fixed_price_quantity` - /// instead of a `price`, `price_id`, or `external_price_id` field. This will - /// update only the quantity for the price, similar to the [Update price quantity](/api-reference/subscription/update-price-quantity) endpoint. + /// instead of a `price`, `price_id`, or `external_price_id` field. This will update + /// only the quantity for the price, similar to the [Update price + /// quantity](/api-reference/subscription/update-price-quantity) endpoint. /// /// The replacement price will have the same phase, if applicable, and the /// same start and end dates as the price it replaces. /// - /// An object in the list can specify an optional `minimum_amount`, `maximum_amount`, - /// or `discounts`. This will create adjustments which apply only to this price. + /// An object in the list can specify an optional `minimum_amount`, + /// `maximum_amount`, or `discounts`. This will create adjustments which apply only + /// to this price. /// - /// Additionally, an object in the list can specify an optional `reference_id`. - /// This ID can be used to reference the replacement price when [adding an adjustment](#adding-adjustments) - /// in the same API call. However the ID is _transient_ and cannot be used to - /// refer to the price in future API calls. + /// Additionally, an object in the list can specify an optional + /// `reference_id`. This ID can be used to reference the replacement price when + /// [adding an adjustment](#adding-adjustments) in the same API call. However the ID + /// is _transient_ and cannot be used to refer to the price in future API calls. /// /// ### Adding adjustments /// - /// To add adjustments, provide a list of objects with the key `add_adjustments`. - /// An object in the list must include an object with the key `adjustment`, identical - /// to the adjustment object in the [add/edit price intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). + /// To add adjustments, provide a list of objects with the key + /// `add_adjustments`. An object in the list must include an object with the key + /// `adjustment`, identical to the adjustment object in the [add/edit price + /// intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). /// - /// If the plan has phases, each object in the list must include a number - /// with `plan_phase_order` key to indicate which phase the adjustment should - /// be added to. + /// If the plan has phases, each object in the list must include a number with + /// `plan_phase_order` key to indicate which phase the adjustment should be added + /// to. /// /// An object in the list can specify an optional `start_date` and optional /// `end_date`. If unspecified, the start or end date of the phase or subscription @@ -141,43 +148,45 @@ public interface ISubscriptionService /// /// ### Removing adjustments /// - /// To remove adjustments, provide a list of objects with the key `remove_adjustments`. - /// An object in the list must include a key, `adjustment_id`, with the ID of - /// the adjustment to be removed. + /// To remove adjustments, provide a list of objects with the key + /// `remove_adjustments`. An object in the list must include a key, `adjustment_id`, + /// with the ID of the adjustment to be removed. /// /// ### Replacing adjustments /// - /// To replace adjustments, provide a list of objects with the key `replace_adjustments`. - /// An object in the list must specify a plan adjustment to replace with the - /// `replaces_adjustment_id` key, and it must specify an adjustment to replace - /// it with by including an object with the key `adjustment`, identical to the - /// adjustment object in the [add/edit price intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). + /// To replace adjustments, provide a list of objects with the key + /// `replace_adjustments`. An object in the list must specify a plan adjustment to + /// replace with the `replaces_adjustment_id` key, and it must specify an adjustment + /// to replace it with by including an object with the key `adjustment`, identical + /// to the adjustment object in the [add/edit price intervals + /// endpoint](/api-reference/price-interval/add-or-edit-price-intervals). /// - /// The replacement adjustment will have the same phase, if applicable, - /// and the same start and end dates as the adjustment it replaces. + /// The replacement adjustment will have the same phase, if applicable, and + /// the same start and end dates as the adjustment it replaces. /// /// ## Price overrides (DEPRECATED) /// - /// Price overrides are being phased out in favor adding/removing/replacing - /// prices. (See [Customize your customer's subscriptions](/api-reference/subscription/create-subscription)) + /// Price overrides are being phased out in favor + /// adding/removing/replacing prices. (See [Customize your customer's + /// subscriptions](/api-reference/subscription/create-subscription)) /// - /// Price overrides are used to update some or all prices in a plan for - /// the specific subscription being created. This is useful when a new customer - /// has negotiated a rate that is unique to the customer. + /// Price overrides are used to update some or all prices in a plan for the + /// specific subscription being created. This is useful when a new customer has + /// negotiated a rate that is unique to the customer. /// - /// To override prices, provide a list of objects with the key `price_overrides`. - /// The price object in the list of overrides is expected to contain the existing - /// price id, the `model_type` and configuration. (See the [Price resource](/product-catalog/price-configuration) - /// for the specification of different price model configurations.) The numerical - /// values can be updated, but the billable metric, cadence, type, and name of - /// a price can not be overridden. + /// To override prices, provide a list of objects with the key + /// `price_overrides`. The price object in the list of overrides is expected to + /// contain the existing price id, the `model_type` and configuration. (See the + /// [Price resource](/product-catalog/price-configuration) for the specification of + /// different price model configurations.) The numerical values can be updated, but + /// the billable metric, cadence, type, and name of a price can not be overridden. /// - /// ### Maximums and Minimums Minimums and maximums, much like price overrides, - /// can be useful when a new customer has negotiated a new or different minimum - /// or maximum spend cap than the default for a given price. If one exists for - /// a price and null is provided for the minimum/maximum override on creation, - /// then there will be no minimum/maximum on the new subscription. If no value - /// is provided, then the default price maximum or minimum is used. + /// ### Maximums and Minimums Minimums and maximums, much like price + /// overrides, can be useful when a new customer has negotiated a new or different + /// minimum or maximum spend cap than the default for a given price. If one exists + /// for a price and null is provided for the minimum/maximum override on creation, + /// then there will be no minimum/maximum on the new subscription. If no value is + /// provided, then the default price maximum or minimum is used. /// /// To add a minimum for a specific price, add `minimum_amount` to the /// specific price in the `price_overrides` object. @@ -189,40 +198,41 @@ public interface ISubscriptionService /// /// Price minimum override example: /// - /// ```json { ... "id": "price_id", "model_type": "unit", "unit_config": - /// { "unit_amount": "0.50" }, "minimum_amount": "100.00" ... } ``` + /// ```json { ... "id": "price_id", "model_type": "unit", + /// "unit_config": { "unit_amount": "0.50" }, "minimum_amount": "100.00" + /// ... } ``` /// /// Removing an existing minimum example ```json { ... "id": "price_id", - /// "model_type": "unit", "unit_config": { "unit_amount": "0.50" }, - /// "minimum_amount": null ... } ``` + /// "model_type": "unit", "unit_config": { "unit_amount": "0.50" }, + /// "minimum_amount": null ... } ``` /// - /// ### Discounts Discounts, like price overrides, can be useful when a - /// new customer has negotiated a new or different discount than the default for - /// a price. If a discount exists for a price and a null discount is provided - /// on creation, then there will be no discount on the new subscription. + /// ### Discounts Discounts, like price overrides, can be useful when a new + /// customer has negotiated a new or different discount than the default for a + /// price. If a discount exists for a price and a null discount is provided on + /// creation, then there will be no discount on the new subscription. /// - /// To add a discount for a specific price, add `discount` to the price - /// in the `price_overrides` object. Discount should be a dictionary of the format: - /// ```ts { "discount_type": "amount" | "percentage" | "usage", "amount_discount": - /// string, "percentage_discount": string, "usage_discount": string } ``` - /// where either `amount_discount`, `percentage_discount`, or `usage_discount` - /// is provided. + /// To add a discount for a specific price, add `discount` to the price in the + /// `price_overrides` object. Discount should be a dictionary of the format: ```ts { + /// "discount_type": "amount" | "percentage" | "usage", "amount_discount": + /// string, "percentage_discount": string, "usage_discount": string } ``` where + /// either `amount_discount`, `percentage_discount`, or `usage_discount` is + /// provided. /// /// Price discount example ```json { ... "id": "price_id", "model_type": - /// "unit", "unit_config": { "unit_amount": "0.50" }, "discount": {"discount_type": - /// "amount", "amount_discount": "175"}, } ``` + /// "unit", "unit_config": { "unit_amount": "0.50" }, "discount": + /// {"discount_type": "amount", "amount_discount": "175"}, } ``` /// - /// Removing an existing discount example ```json { "customer_id": "customer_id", - /// "plan_id": "plan_id", "discount": null, "price_overrides": [ ... ] - /// ... } ``` + /// Removing an existing discount example ```json { "customer_id": + /// "customer_id", "plan_id": "plan_id", "discount": null, "price_overrides": + /// [ ... ] ... } ``` /// /// ## Threshold Billing /// /// Orb supports invoicing for a subscription when a preconfigured usage /// threshold is hit. To enable threshold billing, pass in an `invoicing_threshold`, - /// which is specified in the subscription's invoicing currency, when creating - /// a subscription. E.g. pass in `10.00` to issue an invoice when usage amounts - /// hit \$10.00 for a subscription that invoices in USD. + /// which is specified in the subscription's invoicing currency, when creating a + /// subscription. E.g. pass in `10.00` to issue an invoice when usage amounts hit + /// \$10.00 for a subscription that invoices in USD. /// /// ## Limits By default, Orb limits the number of subscriptions per customer /// to 100. @@ -233,8 +243,9 @@ Task Create( ); /// - /// This endpoint can be used to update the `metadata`, `net terms`, `auto_collection`, - /// `invoicing_threshold`, and `default_invoice_memo` properties on a subscription. + /// This endpoint can be used to update the `metadata`, `net terms`, + /// `auto_collection`, `invoicing_threshold`, and `default_invoice_memo` properties + /// on a subscription. /// Task Update( SubscriptionUpdateParams parameters, @@ -249,13 +260,15 @@ Task Update( ); /// - /// This endpoint returns a list of all subscriptions for an account 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). - /// - /// 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. + /// This endpoint returns a list of all subscriptions for an account 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). + /// + /// 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. /// Task List( SubscriptionListParams? parameters = null, @@ -263,60 +276,61 @@ Task List( ); /// - /// This endpoint can be used to cancel an existing subscription. It returns - /// the serialized subscription object with an `end_date` parameter that signifies - /// when the subscription will transition to an ended state. + /// This endpoint can be used to cancel an existing subscription. It returns the + /// serialized subscription object with an `end_date` parameter that signifies when + /// the subscription will transition to an ended state. /// /// The body parameter `cancel_option` determines the cancellation behavior. - /// Orb supports three cancellation options: - `end_of_subscription_term`: stops - /// the subscription from auto-renewing. Subscriptions that have been cancelled - /// with this option can still incur charges for the remainder of their term: - /// - Issuing this cancellation request for a monthly subscription will keep - /// the subscription active until the start of the subsequent month, and + /// Orb supports three cancellation options: - `end_of_subscription_term`: stops the + /// subscription from auto-renewing. Subscriptions that have been cancelled with + /// this option can still incur charges for the remainder of their term: - + /// Issuing this cancellation request for a monthly subscription will keep the + /// subscription active until the start of the subsequent month, and /// potentially issue an invoice for any usage charges incurred in the intervening - /// period. - Issuing this cancellation request for a quarterly subscription + /// period. - Issuing this cancellation request for a quarterly subscription /// will keep the subscription active until the end of the quarter and /// potentially issue an invoice for any usage charges incurred in the intervening - /// period. - Issuing this cancellation request for a yearly subscription - /// will keep the subscription active for the full year. For example, a - /// yearly subscription starting on 2021-11-01 and cancelled on 2021-12-08 will - /// remain active until 2022-11-01 and potentially issue charges in the - /// intervening months for any recurring monthly usage charges in its plan. - /// - **Note**: If a subscription's plan contains prices with difference cadences, - /// the end of term date will be determined by the largest cadence value. - /// For example, cancelling end of term for a subscription with a quarterly - /// fixed fee with a monthly usage fee will result in the subscription ending - /// at the end of the quarter. + /// period. - Issuing this cancellation request for a yearly subscription will + /// keep the subscription active for the full year. For example, a yearly + /// subscription starting on 2021-11-01 and cancelled on 2021-12-08 will remain + /// active until 2022-11-01 and potentially issue charges in the intervening + /// months for any recurring monthly usage charges in its plan. - + /// **Note**: If a subscription's plan contains prices with difference cadences, the + /// end of term date will be determined by the largest cadence value. For + /// example, cancelling end of term for a subscription with a quarterly fixed + /// fee with a monthly usage fee will result in the subscription ending at the end + /// of the quarter. /// /// - `immediate`: ends the subscription immediately, setting the `end_date` /// to the current time: - Subscriptions that have been cancelled with this /// option will be invoiced immediately. This invoice will include any usage /// fees incurred in the billing period up to the cancellation, along with any - /// prorated recurring fees for the billing period, if applicable. - /// - **Note**: If the subscription has a recurring fee that was paid in-advance, - /// the prorated amount for the remaining time period will be added to the - /// [customer's balance](list-balance-transactions) upon immediate cancellation. - /// However, if the customer is ineligible to use the customer balance, the subscription - /// cannot be cancelled immediately. + /// prorated recurring fees for the billing period, if applicable. - + /// **Note**: If the subscription has a recurring fee that was paid in-advance, the + /// prorated amount for the remaining time period will be added to the + /// [customer's balance](list-balance-transactions) upon immediate + /// cancellation. However, if the customer is ineligible to use the customer + /// balance, the subscription cannot be cancelled immediately. /// /// - `requested_date`: ends the subscription on a specified date, which /// requires a `cancellation_date` to be passed in. If no timezone is provided, - /// the customer's timezone is used. For example, a subscription starting on - /// January 1st with a monthly price can be set to be cancelled on the first - /// of any month after January 1st (e.g. March 1st, April 1st, May 1st). A - /// subscription with multiple prices with different cadences defines the "term" - /// to be the highest cadence of the prices. - /// - /// Upcoming subscriptions are only eligible for immediate cancellation, - /// which will set the `end_date` equal to the `start_date` upon cancellation. - /// - /// ## Backdated cancellations Orb allows you to cancel a subscription - /// in the past as long as there are no paid invoices between the `requested_date` - /// and the current time. If the cancellation is after the latest issued invoice, - /// Orb will 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). + /// the customer's timezone is used. For example, a subscription starting on January + /// 1st with a monthly price can be set to be cancelled on the first of any month after + /// January 1st (e.g. March 1st, April 1st, May 1st). A subscription with multiple + /// prices with different cadences defines the "term" to be the highest cadence of + /// the prices. + /// + /// Upcoming subscriptions are only eligible for immediate cancellation, which + /// will set the `end_date` equal to the `start_date` upon cancellation. + /// + /// ## Backdated cancellations Orb allows you to cancel a subscription in the + /// past as long as there are no paid invoices between the `requested_date` and the + /// current time. If the cancellation is after the latest issued invoice, Orb will + /// 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). /// Task Cancel( SubscriptionCancelParams parameters, @@ -347,15 +361,16 @@ Task Fetch( ); /// - /// This endpoint is used to fetch a day-by-day snapshot of a subscription's - /// costs in Orb, calculated by applying pricing information to the underlying - /// usage (see the [subscription usage endpoint](fetch-subscription-usage) to - /// fetch usage per metric, in usage units rather than a currency). - /// - /// The semantics of this endpoint exactly mirror those of [fetching a customer's - /// 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). + /// This endpoint is used to fetch a day-by-day snapshot of a subscription's costs + /// in Orb, calculated by applying pricing information to the underlying usage (see + /// the [subscription usage endpoint](fetch-subscription-usage) to fetch usage per + /// metric, in usage units rather than a currency). + /// + /// The semantics of this endpoint exactly mirror those of [fetching a + /// customer's costs](/api-reference/customer/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). /// Task FetchCosts( SubscriptionFetchCostsParams parameters, @@ -370,10 +385,10 @@ Task FetchCosts( ); /// - /// 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. + /// 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. /// Task FetchSchedule( SubscriptionFetchScheduleParams parameters, @@ -388,120 +403,123 @@ Task FetchSchedule( ); /// - /// This endpoint is used to fetch a subscription's usage in Orb. Especially - /// when combined with optional query parameters, this endpoint is a powerful - /// way to build visualizations on top of Orb's event data and metrics. + /// This endpoint is used to fetch a subscription's usage in Orb. Especially when + /// combined with optional query parameters, this endpoint is a powerful way to + /// build visualizations on top of Orb's event data and metrics. /// - /// With no query parameters specified, this endpoint returns usage for - /// the subscription's _current billing period_ across each billable metric that - /// participates in the subscription. Usage quantities returned are the result - /// of evaluating the metric definition for the entirety of the customer's billing period. + /// With no query parameters specified, this endpoint returns usage for the + /// subscription's _current billing period_ across each billable metric that + /// participates in the subscription. Usage quantities returned are the result of + /// evaluating the metric definition for the entirety of the customer's billing + /// period. /// /// ### Default response shape Orb returns a `data` array with an object /// corresponding to each billable metric. Nested within this object is a `usage` - /// array which has a `quantity` value and a corresponding `timeframe_start` - /// and `timeframe_end`. The `quantity` value represents the calculated usage - /// value for the billable metric over the specified timeframe (inclusive of - /// the `timeframe_start` timestamp and exclusive of the `timeframe_end` timestamp). + /// array which has a `quantity` value and a corresponding `timeframe_start` and + /// `timeframe_end`. The `quantity` value represents the calculated usage value for + /// the billable metric over the specified timeframe (inclusive of the `timeframe_start` + /// timestamp and exclusive of the `timeframe_end` timestamp). /// - /// Orb will include _every_ window in the response starting from the beginning - /// of the billing period, even when there were no events (and therefore no usage) - /// in the window. This increases the size of the response but prevents the caller - /// from filling in gaps and handling cumbersome time-based logic. + /// Orb will include _every_ window in the response starting from the + /// beginning of the billing period, even when there were no events (and therefore + /// no usage) in the window. This increases the size of the response but prevents + /// the caller from filling in gaps and handling cumbersome time-based logic. /// - /// The query parameters in this endpoint serve to override this behavior - /// and provide some key functionality, as listed below. Note that this functionality - /// can also be used _in conjunction_ with each other, e.g. to display grouped - /// usage on a custom timeframe. + /// The query parameters in this endpoint serve to override this behavior and + /// provide some key functionality, as listed below. Note that this functionality + /// can also be used _in conjunction_ with each other, e.g. to display grouped usage + /// on a custom timeframe. /// /// ## Custom timeframe In order to view usage for a custom timeframe rather - /// than the current billing period, specify a `timeframe_start` and `timeframe_end`. - /// This will calculate quantities for usage incurred between timeframe_start - /// (inclusive) and timeframe_end (exclusive), i.e. `[timeframe_start, timeframe_end)`. + /// than the current billing period, specify a `timeframe_start` and + /// `timeframe_end`. This will calculate quantities for usage incurred between + /// timeframe_start (inclusive) and timeframe_end (exclusive), i.e. + /// `[timeframe_start, timeframe_end)`. /// /// Note: - These timestamps must be specified in ISO 8601 format and UTC - /// timezone, e.g. `2022-02-01T05:00:00Z`. - Both parameters must be specified - /// if either is specified. + /// timezone, e.g. `2022-02-01T05:00:00Z`. - Both parameters must be specified if + /// either is specified. /// /// ## Grouping by custom attributes In order to view a single metric grouped - /// by a specific _attribute_ that each event is tagged with (e.g. `cluster`), - /// you must additionally specify a `billable_metric_id` and a `group_by` key. - /// The `group_by` key denotes the event property on which to group. - /// - /// When returning grouped usage, only usage for `billable_metric_id` is - /// returned, and a separate object in the `data` array is returned for each - /// value of the `group_by` key present in your events. The `quantity` value - /// is the result of evaluating the billable metric for events filtered to a single - /// value of the `group_by` key. - /// - /// Orb expects that events that match the billable metric will contain - /// values in the `properties` dictionary that correspond to the `group_by` key - /// specified. By default, Orb will not return a `null` group (i.e. events that - /// match the metric but do not have the key set). Currently, it is only possible - /// to view usage grouped by a single attribute at a time. - /// - /// When viewing grouped usage, Orb uses pagination to limit the response - /// size to 1000 groups by default. If there are more groups for a given subscription, + /// by a specific _attribute_ that each event is tagged with (e.g. `cluster`), you + /// must additionally specify a `billable_metric_id` and a `group_by` key. The + /// `group_by` key denotes the event property on which to group. + /// + /// When returning grouped usage, only usage for `billable_metric_id` is returned, + /// and a separate object in the `data` array is returned for each value of the `group_by` + /// key present in your events. The `quantity` value is the result of evaluating the + /// billable metric for events filtered to a single value of the `group_by` key. + /// + /// Orb expects that events that match the billable metric will contain values + /// in the `properties` dictionary that correspond to the `group_by` key specified. + /// By default, Orb will not return a `null` group (i.e. events that match the + /// metric but do not have the key set). Currently, it is only possible to view + /// usage grouped by a single attribute at a time. + /// + /// When viewing grouped usage, Orb uses pagination to limit the response size + /// to 1000 groups by default. If there are more groups for a given subscription, /// pagination metadata in the response can be used to fetch all of the data. /// /// The following example shows usage for an "API Requests" billable metric /// grouped by `region`. Note the extra `metric_group` dictionary in the response, /// which provides metadata about the group: /// - /// ```json { "data": [ { "usage": [ - /// { "quantity": 0.19291, "timeframe_start": - /// "2021-10-01T07:00:00Z", "timeframe_end": "2021-10-02T07:00:00Z", - /// }, ... ], "metric_group": - /// { "property_key": "region", "property_value": - /// "asia/pacific" }, "billable_metric": { - /// "id": "Fe9pbpMk86xpwdGB", "name": "API Requests" - /// }, "view_mode": "periodic" }, ... - /// ] } ``` - /// - /// ## Windowed usage The `granularity` parameter can be used to _window_ - /// the usage `quantity` value into periods. When not specified, usage is returned - /// for the entirety of the time range. - /// - /// When `granularity = day` is specified with a timeframe longer than a - /// day, Orb will return a `quantity` value for each full day between `timeframe_start` - /// and `timeframe_end`. Note that the days are demarcated by the _customer's - /// local midnight_. + /// ```json { "data": [ { "usage": [ { + /// "quantity": 0.19291, "timeframe_start": + /// "2021-10-01T07:00:00Z", "timeframe_end": + /// "2021-10-02T07:00:00Z", }, ... ], + /// "metric_group": { "property_key": "region", + /// "property_value": "asia/pacific" }, + /// "billable_metric": { "id": "Fe9pbpMk86xpwdGB", + /// "name": "API Requests" }, "view_mode": "periodic" + /// }, ... ] } ``` + /// + /// ## Windowed usage The `granularity` parameter can be used to _window_ the + /// usage `quantity` value into periods. When not specified, usage is returned for + /// the entirety of the time range. + /// + /// When `granularity = day` is specified with a timeframe longer than a day, + /// Orb will return a `quantity` value for each full day between `timeframe_start` + /// and `timeframe_end`. Note that the days are demarcated by the _customer's local + /// midnight_. /// /// For example, with `timeframe_start = 2022-02-01T05:00:00Z`, `timeframe_end - /// = 2022-02-04T01:00:00Z` and `granularity=day`, the following windows will - /// be returned for a customer in the `America/Los_Angeles` timezone since local - /// midnight is `08:00` UTC: - `[2022-02-01T05:00:00Z, 2022-02-01T08:00:00Z)` - /// - `[2022-02-01T08:00:00, 2022-02-02T08:00:00Z)` - `[2022-02-02T08:00:00, + /// = 2022-02-04T01:00:00Z` and `granularity=day`, the following windows will be + /// returned for a customer in the `America/Los_Angeles` timezone since local + /// midnight is `08:00` UTC: - `[2022-02-01T05:00:00Z, 2022-02-01T08:00:00Z)` - + /// `[2022-02-01T08:00:00, 2022-02-02T08:00:00Z)` - `[2022-02-02T08:00:00, /// 2022-02-03T08:00:00Z)` - `[2022-02-03T08:00:00, 2022-02-04T01:00:00Z)` /// /// ```json { "data": [ { "billable_metric": { - /// "id": "Q8w89wjTtBdejXKsm", "name": "API Requests" - /// }, "usage": [ { - /// "quantity": 0, "timeframe_end": "2022-02-01T08:00:00+00:00", + /// "id": "Q8w89wjTtBdejXKsm", "name": "API Requests" + /// }, "usage": [ { + /// "quantity": 0, "timeframe_end": "2022-02-01T08:00:00+00:00", /// "timeframe_start": "2022-02-01T05:00:00+00:00" - /// }, { + /// }, { /// /// "quantity": 0, "timeframe_end": - /// "2022-02-02T08:00:00+00:00", "timeframe_start": "2022-02-01T08:00:00+00:00" - /// }, { "quantity": 0, - /// "timeframe_end": "2022-02-03T08:00:00+00:00", - /// "timeframe_start": "2022-02-02T08:00:00+00:00" - /// }, { "quantity": 0, - /// "timeframe_end": "2022-02-04T01:00:00+00:00", "timeframe_start": + /// "2022-02-02T08:00:00+00:00", "timeframe_start": + /// "2022-02-01T08:00:00+00:00" }, { + /// "quantity": 0, "timeframe_end": + /// "2022-02-03T08:00:00+00:00", "timeframe_start": + /// "2022-02-02T08:00:00+00:00" }, { + /// "quantity": 0, "timeframe_end": + /// "2022-02-04T01:00:00+00:00", "timeframe_start": /// "2022-02-03T08:00:00+00:00" } ], /// "view_mode": "periodic" }, ... ] } ``` /// - /// ## Decomposable vs. non-decomposable metrics Billable metrics fall - /// into one of two categories: decomposable and non-decomposable. A decomposable + /// ## Decomposable vs. non-decomposable metrics Billable metrics fall into + /// one of two categories: decomposable and non-decomposable. A decomposable /// billable metric, such as a sum or a count, can be displayed and aggregated - /// across arbitrary timescales. On the other hand, a non-decomposable metric - /// is not meaningful when only a slice of the billing window is considered. + /// across arbitrary timescales. On the other hand, a non-decomposable metric is not + /// meaningful when only a slice of the billing window is considered. /// - /// As an example, if we have a billable metric that's defined to count - /// unique users, displaying a graph of unique users for each day is not representative - /// of the billable metric value over the month (days could have an overlapping - /// set of 'unique' users). Instead, what's useful for any given day is the number - /// of unique users in the billing period so far, which are the _cumulative_ unique users. + /// As an example, if we have a billable metric that's defined to count unique + /// users, displaying a graph of unique users for each day is not representative of + /// the billable metric value over the month (days could have an overlapping set of + /// 'unique' users). Instead, what's useful for any given day is the number of + /// unique users in the billing period so far, which are the _cumulative_ unique + /// users. /// /// Accordingly, this endpoint returns treats these two types of metrics /// differently when `group_by` is specified: - Decomposable metrics can be grouped @@ -509,18 +527,18 @@ Task FetchSchedule( /// corresponding price's invoice grouping key. If no invoice grouping key is /// present, the metric does not support `group_by`. /// - /// ## Matrix prices When a billable metric is attached to a price that - /// uses matrix pricing, it's important to view usage grouped by those matrix - /// dimensions. In this case, use the query parameters `first_dimension_key`, + /// ## Matrix prices When a billable metric is attached to a price that uses + /// matrix pricing, it's important to view usage grouped by those matrix dimensions. + /// In this case, use the query parameters `first_dimension_key`, /// `first_dimension_value` and `second_dimension_key`, `second_dimension_value` /// while filtering to a specific `billable_metric_id`. /// - /// For example, if your compute metric has a separate unit price (i.e. - /// a matrix pricing model) per `region` and `provider`, your request might provide + /// For example, if your compute metric has a separate unit price (i.e. a + /// matrix pricing model) per `region` and `provider`, your request might provide /// the following parameters: /// - /// - `first_dimension_key`: `region` - `first_dimension_value`: `us-east-1` - /// - `second_dimension_key`: `provider` - `second_dimension_value`: `aws` + /// - `first_dimension_key`: `region` - `first_dimension_value`: `us-east-1` - + /// `second_dimension_key`: `provider` - `second_dimension_value`: `aws` /// Task FetchUsage( SubscriptionFetchUsageParams parameters, @@ -535,75 +553,77 @@ Task FetchUsage( ); /// - /// This endpoint is used to add and edit subscription [price intervals](/api-reference/price-interval/add-or-edit-price-intervals). - /// By making modifications to a subscription’s price intervals, you can [flexibly - /// and atomically control the billing behavior of a subscription](/product-catalog/modifying-subscriptions). + /// This endpoint is used to add and edit subscription [price + /// intervals](/api-reference/price-interval/add-or-edit-price-intervals). By making + /// modifications to a subscription’s price intervals, you can [flexibly and + /// atomically control the billing behavior of a + /// subscription](/product-catalog/modifying-subscriptions). /// /// ## Adding price intervals /// /// Prices can be added as price intervals to a subscription by specifying /// them in the `add` array. A `price_id` or `external_price_id` from an add-on /// price or previously removed plan price can be specified to reuse an existing - /// price definition (however, please note that prices from other plans cannot - /// be added to the subscription). Additionally, a new price can be specified - /// using the `price` field — this price will be created automatically. - /// - /// A `start_date` must be specified for the price interval. This is the - /// date when the price will start billing on the subscription, so this will notably - /// result in an immediate charge at this time for any billed in advance fixed - /// fees. The `end_date` will default to null, resulting in a price interval - /// that will bill on a continually recurring basis. Both of these dates can be - /// set in the past or the future and Orb will generate or modify invoices to - /// ensure the subscription’s invoicing behavior is correct. + /// price definition (however, please note that prices from other plans cannot be + /// added to the subscription). Additionally, a new price can be specified using the + /// `price` field — this price will be created automatically. + /// + /// A `start_date` must be specified for the price interval. This is the date + /// when the price will start billing on the subscription, so this will notably + /// result in an immediate charge at this time for any billed in advance fixed fees. + /// The `end_date` will default to null, resulting in a price interval that will + /// bill on a continually recurring basis. Both of these dates can be set in the + /// past or the future and Orb will generate or modify invoices to ensure the + /// subscription’s invoicing behavior is correct. /// /// Additionally, a discount, minimum, or maximum can be specified on the - /// price interval. This will only apply to this price interval, not any other - /// price intervals on the subscription. + /// price interval. This will only apply to this price interval, not any other price + /// intervals on the subscription. /// /// ## Adjustment intervals /// /// An adjustment interval represents the time period that a particular - /// adjustment (a discount, minimum, or maximum) applies to the prices on a subscription. - /// Adjustment intervals can be added to a subscription by specifying them in - /// the `add_adjustments` array, or modified via the `edit_adjustments` array. - /// When creating an adjustment interval, you'll need to provide the definition - /// of the new adjustment (the type of adjustment, and which prices it applies - /// to), as well as the start and end dates for the adjustment interval. The + /// adjustment (a discount, minimum, or maximum) applies to the prices on a + /// subscription. Adjustment intervals can be added to a subscription by specifying + /// them in the `add_adjustments` array, or modified via the `edit_adjustments` + /// array. When creating an adjustment interval, you'll need to provide the + /// definition of the new adjustment (the type of adjustment, and which prices it + /// applies to), as well as the start and end dates for the adjustment interval. The /// start and end dates of an existing adjustment interval can be edited via the - /// `edit_adjustments` field (just like price intervals). (To "change" the amount - /// of a discount, minimum, or maximum, then, you'll need to end the existing - /// interval, and create a new adjustment interval with the new amount and a - /// start date that matches the end date of the previous interval.) + /// `edit_adjustments` field (just like price intervals). (To "change" the amount of + /// a discount, minimum, or maximum, then, you'll need to end the existing interval, + /// and create a new adjustment interval with the new amount and a start date that + /// matches the end date of the previous interval.) /// /// ## Editing price intervals /// - /// Price intervals can be adjusted by specifying edits to make in the - /// `edit` array. A `price_interval_id` to edit must be specified — this can - /// be retrieved from the `price_intervals` field on the subscription. - /// - /// A new `start_date` or `end_date` can be specified to change the range - /// of the price interval, which will modify past or future invoices to ensure - /// correctness. If either of these dates are unspecified, they will default - /// to the existing date on the price interval. To remove a price interval entirely - /// from a subscription, set the `end_date` to be equivalent to the `start_date`. - /// - /// ## Fixed fee quantity transitions The fixed fee quantity transitions - /// for a fixed fee price interval can also be specified when adding or editing - /// by passing an array for `fixed_fee_quantity_transitions`. A fixed fee quantity - /// transition must have a `quantity` and an `effective_date`, which is the date - /// after which the new quantity will be used for billing. If a fixed fee quantity - /// transition is scheduled at a billing period boundary, the full quantity will - /// be billed on an invoice with the other prices on the subscription. If the - /// fixed fee quantity transition is scheduled mid-billing period, the difference - /// between the existing quantity and quantity specified in the transition will - /// be prorated for the rest of the billing period and billed immediately, which - /// will generate a new invoice. + /// Price intervals can be adjusted by specifying edits to make in the `edit` + /// array. A `price_interval_id` to edit must be specified — this can be retrieved + /// from the `price_intervals` field on the subscription. + /// + /// A new `start_date` or `end_date` can be specified to change the range of + /// the price interval, which will modify past or future invoices to ensure + /// correctness. If either of these dates are unspecified, they will default to the + /// existing date on the price interval. To remove a price interval entirely from a + /// subscription, set the `end_date` to be equivalent to the `start_date`. + /// + /// ## Fixed fee quantity transitions The fixed fee quantity transitions for a + /// fixed fee price interval can also be specified when adding or editing by passing + /// an array for `fixed_fee_quantity_transitions`. A fixed fee quantity transition + /// must have a `quantity` and an `effective_date`, which is the date after which + /// the new quantity will be used for billing. If a fixed fee quantity transition is + /// scheduled at a billing period boundary, the full quantity will be billed on an + /// invoice with the other prices on the subscription. If the fixed fee quantity + /// transition is scheduled mid-billing period, the difference between the existing + /// quantity and quantity specified in the transition will be prorated for the rest + /// of the billing period and billed immediately, which will generate a new invoice. /// /// Notably, the list of fixed fee quantity transitions passed will overwrite - /// the existing fixed fee quantity transitions on the price interval, so the - /// entire 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. + /// the existing fixed fee quantity transitions on the price interval, so the entire + /// 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. /// Task PriceIntervals( SubscriptionPriceIntervalsParams parameters, @@ -637,163 +657,172 @@ Task RedeemCoupon( /// the serialized updated subscription object. /// /// The body parameter `change_option` determines when the plan change occurs. - /// Orb supports three options: - `end_of_subscription_term`: changes the plan - /// at the end of the existing plan's term. - Issuing this plan change request - /// for a monthly subscription will keep the existing plan active until the start - /// of the subsequent month. Issuing this plan change request for a yearly + /// Orb supports three options: - `end_of_subscription_term`: changes the plan at + /// the end of the existing plan's term. - Issuing this plan change request for + /// a monthly subscription will keep the existing plan active until the start + /// of the subsequent month. Issuing this plan change request for a yearly /// subscription will keep the existing plan active for the full year. Charges - /// incurred in the remaining period will be invoiced as normal. - Example: - /// The plan is billed monthly on the 1st of the month, the request is made on - /// January 15th, so the plan will be changed on February 1st, and invoice - /// will be issued on February 1st for the last month of the original plan. - - /// `immediate`: changes the plan immediately. - Subscriptions that have their - /// plan changed with this option will move to the new plan immediately, and be - /// invoiced immediately. - This invoice will include any usage fees - /// incurred in the billing period up to the change, along with any prorated - /// recurring fees for the billing period, if applicable. - Example: - /// The plan is billed monthly on the 1st of the month, the request is made on - /// January 15th, so the plan will be changed on January 15th, and an invoice - /// will be issued for the partial month, from January 1 to January 15, on the - /// original plan. - `requested_date`: changes the plan on the requested - /// date (`change_date`). - If no timezone is provided, the customer's timezone - /// is used. The `change_date` body parameter is required if this option - /// is chosen. - Example: The plan is billed monthly on the 1st of the - /// month, the request is made on January 15th, with a requested `change_date` - /// of February 15th, so the plan will be changed on February 15th, and invoices - /// will be issued on February 1st and February 15th. + /// incurred in the remaining period will be invoiced as normal. - Example: The + /// plan is billed monthly on the 1st of the month, the request is made on January + /// 15th, so the plan will be changed on February 1st, and invoice will be + /// issued on February 1st for the last month of the original plan. - `immediate`: + /// changes the plan immediately. - Subscriptions that have their plan changed + /// with this option will move to the new plan immediately, and be invoiced + /// immediately. - This invoice will include any usage fees incurred in the + /// billing period up to the change, along with any prorated recurring fees + /// for the billing period, if applicable. - Example: The plan is billed monthly + /// on the 1st of the month, the request is made on January 15th, so the plan will + /// be changed on January 15th, and an invoice will be issued for the partial + /// month, from January 1 to January 15, on the original plan. - + /// `requested_date`: changes the plan on the requested date (`change_date`). - + /// If no timezone is provided, the customer's timezone is used. The `change_date` + /// body parameter is required if this option is chosen. - Example: The + /// plan is billed monthly on the 1st of the month, the request is made on January + /// 15th, with a requested `change_date` of February 15th, so the plan will be + /// changed on February 15th, and invoices will be issued on February 1st and + /// February 15th. /// /// Note that one of `plan_id` or `external_plan_id` is required in the /// request body for this operation. /// /// ## Customize your customer's subscriptions /// - /// Prices and adjustments in a plan can be added, removed, or replaced - /// on the subscription when you schedule the plan change. This is useful when - /// a customer has prices that differ from the default prices for a specific plan. + /// Prices and adjustments in a plan can be added, removed, or replaced on the + /// subscription when you schedule the plan change. This is useful when a customer + /// has prices that differ from the default prices for a specific plan. /// - /// This feature is only available for accounts that have migrated - /// to Subscription Overrides Version 2. You can find your Subscription Overrides - /// Version at the bottom of your [Plans page](https://app.withorb.com/plans) + /// This feature is only available for accounts that have migrated to + /// Subscription Overrides Version 2. You can find your Subscription Overrides + /// Version at the bottom of your [Plans page](https://app.withorb.com/plans) + /// /// /// ### Adding Prices /// - /// To add prices, provide a list of objects with the key `add_prices`. - /// An object in the list must specify an existing add-on price with a `price_id` - /// or `external_price_id` field, or create a new add-on price by including an - /// object with the key `price`, identical to what would be used in the request - /// body for the [create price endpoint](/api-reference/price/create-price). - /// See the [Price resource](/product-catalog/price-configuration) for the specification - /// of different price model configurations possible in this object. + /// To add prices, provide a list of objects with the key `add_prices`. An + /// object in the list must specify an existing add-on price with a `price_id` or + /// `external_price_id` field, or create a new add-on price by including an object + /// with the key `price`, identical to what would be used in the request body for + /// the [create price endpoint](/api-reference/price/create-price). See the [Price + /// resource](/product-catalog/price-configuration) for the specification of + /// different price model configurations possible in this object. /// - /// If the plan has phases, each object in the list must include a number - /// with `plan_phase_order` key to indicate which phase the price should be added to. + /// If the plan has phases, each object in the list must include a number with + /// `plan_phase_order` key to indicate which phase the price should be added to. /// /// An object in the list can specify an optional `start_date` and optional - /// `end_date`. If `start_date` is unspecified, the start of the phase / plan - /// change time will be used. If `end_date` is unspecified, it will finish at - /// the end of the phase / have no end time. + /// `end_date`. If `start_date` is unspecified, the start of the phase / plan change + /// time will be used. If `end_date` is unspecified, it will finish at the end of + /// the phase / have no end time. /// - /// An object in the list can specify an optional `minimum_amount`, `maximum_amount`, - /// or `discounts`. This will create adjustments which apply only to this price. + /// An object in the list can specify an optional `minimum_amount`, + /// `maximum_amount`, or `discounts`. This will create adjustments which apply only + /// to this price. /// - /// Additionally, an object in the list can specify an optional `reference_id`. - /// This ID can be used to reference this price when [adding an adjustment](#adding-adjustments) - /// in the same API call. However the ID is _transient_ and cannot be used to - /// refer to the price in future API calls. + /// Additionally, an object in the list can specify an optional + /// `reference_id`. This ID can be used to reference this price when [adding an + /// adjustment](#adding-adjustments) in the same API call. However the ID is + /// _transient_ and cannot be used to refer to the price in future API calls. /// /// ### Removing Prices /// /// To remove prices, provide a list of objects with the key `remove_prices`. - /// An object in the list must specify a plan price with either a `price_id` - /// or `external_price_id` field. + /// An object in the list must specify a plan price with either a `price_id` or + /// `external_price_id` field. /// /// ### Replacing Prices /// - /// To replace prices, provide a list of objects with the key `replace_prices`. - /// An object in the list must specify a plan price to replace with the `replaces_price_id` - /// key, and it must specify a price to replace it with by either referencing - /// an existing add-on price with a `price_id` or `external_price_id` field, or - /// by creating a new add-on price by including an object with the key `price`, - /// identical to what would be used in the request body for the [create price - /// endpoint](/api-reference/price/create-price). See the [Price resource](/product-catalog/price-configuration) - /// for the specification of different price model configurations possible in - /// this object. + /// To replace prices, provide a list of objects with the key + /// `replace_prices`. An object in the list must specify a plan price to replace + /// with the `replaces_price_id` key, and it must specify a price to replace it with + /// by either referencing an existing add-on price with a `price_id` or + /// `external_price_id` field, or by creating a new add-on price by including an + /// object with the key `price`, identical to what would be used in the request body + /// for the [create price endpoint](/api-reference/price/create-price). See the + /// [Price resource](/product-catalog/price-configuration) for the specification of + /// different price model configurations possible in this object. /// /// For fixed fees, an object in the list can supply a `fixed_price_quantity` - /// instead of a `price`, `price_id`, or `external_price_id` field. This will - /// update only the quantity for the price, similar to the [Update price quantity](/api-reference/subscription/update-price-quantity) endpoint. + /// instead of a `price`, `price_id`, or `external_price_id` field. This will update + /// only the quantity for the price, similar to the [Update price + /// quantity](/api-reference/subscription/update-price-quantity) endpoint. /// /// The replacement price will have the same phase, if applicable, and the /// same start and end dates as the price it replaces. /// - /// An object in the list can specify an optional `minimum_amount`, `maximum_amount`, - /// or `discounts`. This will create adjustments which apply only to this price. + /// An object in the list can specify an optional `minimum_amount`, + /// `maximum_amount`, or `discounts`. This will create adjustments which apply only + /// to this price. /// - /// Additionally, an object in the list can specify an optional `reference_id`. - /// This ID can be used to reference the replacement price when [adding an adjustment](#adding-adjustments) - /// in the same API call. However the ID is _transient_ and cannot be used to - /// refer to the price in future API calls. + /// Additionally, an object in the list can specify an optional + /// `reference_id`. This ID can be used to reference the replacement price when + /// [adding an adjustment](#adding-adjustments) in the same API call. However the ID + /// is _transient_ and cannot be used to refer to the price in future API calls. /// /// ### Adding adjustments /// - /// To add adjustments, provide a list of objects with the key `add_adjustments`. - /// An object in the list must include an object with the key `adjustment`, identical - /// to the adjustment object in the [add/edit price intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). + /// To add adjustments, provide a list of objects with the key + /// `add_adjustments`. An object in the list must include an object with the key + /// `adjustment`, identical to the adjustment object in the [add/edit price + /// intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). /// - /// If the plan has phases, each object in the list must include a number - /// with `plan_phase_order` key to indicate which phase the adjustment should - /// be added to. + /// If the plan has phases, each object in the list must include a number with + /// `plan_phase_order` key to indicate which phase the adjustment should be added + /// to. /// /// An object in the list can specify an optional `start_date` and optional - /// `end_date`. If `start_date` is unspecified, the start of the phase / plan - /// change time will be used. If `end_date` is unspecified, it will finish at - /// the end of the phase / have no end time. + /// `end_date`. If `start_date` is unspecified, the start of the phase / plan change + /// time will be used. If `end_date` is unspecified, it will finish at the end of + /// the phase / have no end time. /// /// ### Removing adjustments /// - /// To remove adjustments, provide a list of objects with the key `remove_adjustments`. - /// An object in the list must include a key, `adjustment_id`, with the ID of - /// the adjustment to be removed. + /// To remove adjustments, provide a list of objects with the key + /// `remove_adjustments`. An object in the list must include a key, `adjustment_id`, + /// with the ID of the adjustment to be removed. /// /// ### Replacing adjustments /// - /// To replace adjustments, provide a list of objects with the key `replace_adjustments`. - /// An object in the list must specify a plan adjustment to replace with the - /// `replaces_adjustment_id` key, and it must specify an adjustment to replace - /// it with by including an object with the key `adjustment`, identical to the - /// adjustment object in the [add/edit price intervals endpoint](/api-reference/price-interval/add-or-edit-price-intervals). + /// To replace adjustments, provide a list of objects with the key + /// `replace_adjustments`. An object in the list must specify a plan adjustment to + /// replace with the `replaces_adjustment_id` key, and it must specify an adjustment + /// to replace it with by including an object with the key `adjustment`, identical + /// to the adjustment object in the [add/edit price intervals + /// endpoint](/api-reference/price-interval/add-or-edit-price-intervals). /// - /// The replacement adjustment will have the same phase, if applicable, - /// and the same start and end dates as the adjustment it replaces. + /// The replacement adjustment will have the same phase, if applicable, and + /// the same start and end dates as the adjustment it replaces. /// /// ## Price overrides (DEPRECATED) /// - /// Price overrides are being phased out in favor adding/removing/replacing - /// prices. (See [Customize your customer's subscriptions](/api-reference/subscription/schedule-plan-change)) + /// Price overrides are being phased out in favor + /// adding/removing/replacing prices. (See [Customize your customer's + /// subscriptions](/api-reference/subscription/schedule-plan-change)) /// - /// Price overrides are used to update some or all prices in a plan for - /// the specific subscription being created. This is useful when a new customer - /// has negotiated a rate that is unique to the customer. + /// Price overrides are used to update some or all prices in a plan for the + /// specific subscription being created. This is useful when a new customer has + /// negotiated a rate that is unique to the customer. /// - /// To override prices, provide a list of objects with the key `price_overrides`. - /// The price object in the list of overrides is expected to contain the existing - /// price id, the `model_type` and configuration. (See the [Price resource](/product-catalog/price-configuration) - /// for the specification of different price model configurations.) The numerical - /// values can be updated, but the billable metric, cadence, type, and name of - /// a price can not be overridden. + /// To override prices, provide a list of objects with the key + /// `price_overrides`. The price object in the list of overrides is expected to + /// contain the existing price id, the `model_type` and configuration. (See the + /// [Price resource](/product-catalog/price-configuration) for the specification of + /// different price model configurations.) The numerical values can be updated, but + /// the billable metric, cadence, type, and name of a price can not be overridden. /// - /// ### Maximums, and minimums Price overrides are used to update some or - /// all prices in the target plan. Minimums and maximums, much like price overrides, - /// can be useful when a new customer has negotiated a new or different minimum - /// or maximum spend cap than the default for the plan. The request format for - /// maximums and minimums is the same as those in [subscription creation](create-subscription). + /// ### Maximums, and minimums Price overrides are used to update some or all + /// prices in the target plan. Minimums and maximums, much like price overrides, can + /// be useful when a new customer has negotiated a new or different minimum or + /// maximum spend cap than the default for the plan. The request format for maximums + /// and minimums is the same as those in [subscription + /// creation](create-subscription). /// /// ## Scheduling multiple plan changes When scheduling multiple plan changes /// with the same date, the latest plan change on that day takes effect. /// /// ## 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). + /// balance as needed. For details on this behavior, see [Modifying + /// subscriptions](/product-catalog/modifying-subscriptions#prorations-for-in-advance-fees). /// Task SchedulePlanChange( SubscriptionSchedulePlanChangeParams parameters, @@ -808,8 +837,8 @@ Task SchedulePlanChange( ); /// - /// Manually trigger a phase, effective the given date (or the current time, - /// if not specified). + /// Manually trigger a phase, effective the given date (or the current time, if not + /// specified). /// Task TriggerPhase( SubscriptionTriggerPhaseParams parameters, @@ -824,11 +853,12 @@ Task TriggerPhase( ); /// - /// This endpoint can be used to unschedule any pending cancellations for a subscription. + /// This endpoint can be used to unschedule any pending cancellations for a + /// subscription. /// /// 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. + /// future cancellation. This operation will turn on auto-renew, ensuring that the + /// subscription does not end at the currently scheduled cancellation time. /// Task UnscheduleCancellation( SubscriptionUnscheduleCancellationParams parameters, @@ -843,8 +873,8 @@ Task UnscheduleCancellation( ); /// - /// This endpoint can be used to clear scheduled updates to the quantity for a - /// fixed fee. + /// This endpoint can be used to clear scheduled updates to the quantity for a fixed + /// fee. /// /// If there are no updates scheduled, a request validation error will be /// returned with a 400 status code. @@ -883,10 +913,12 @@ Task UnschedulePendingPlanChanges( /// To be eligible, the subscription must currently be active and the price /// specified must be a fixed fee (not usage-based). This operation will immediately /// update the quantity for the fee, or if a `effective_date` is passed in, will - /// update the quantity on the requested date at midnight in the customer's timezone. + /// update the quantity on the requested date at midnight in the customer's + /// timezone. /// - /// In order to change the fixed fee quantity as of the next draft invoice - /// for this subscription, pass `change_option=upcoming_invoice` without an `effective_date` specified. + /// In order to change the fixed fee quantity as of the next draft invoice for + /// this subscription, pass `change_option=upcoming_invoice` without an + /// `effective_date` specified. /// /// 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. @@ -904,24 +936,24 @@ Task UpdateFixedFeeQuantity( ); /// - /// This endpoint is used to update the trial end date for a subscription. The - /// new trial end date must be within the time range of the current plan (i.e. - /// the new trial end date must be on or after the subscription's start date on - /// the current plan, and on or before the subscription end date). + /// This endpoint is used to update the trial end date for a subscription. The new + /// trial end date must be within the time range of the current plan (i.e. the new + /// trial end date must be on or after the subscription's start date on the current + /// plan, and on or before the subscription end date). /// - /// In order to retroactively remove a trial completely, the end date can - /// be set to the transition date of the subscription to this plan (or, if this - /// is the first plan for this subscription, the subscription's start date). - /// In order to end a trial immediately, the keyword `immediate` can be provided - /// as the trial end date. + /// In order to retroactively remove a trial completely, the end date can be + /// set to the transition date of the subscription to this plan (or, if this is the + /// first plan for this subscription, the subscription's start date). In order to + /// end a trial immediately, the keyword `immediate` can be provided as the trial + /// end date. /// /// By default, Orb will shift only the trial end date (and price intervals /// that start or end on the previous trial end date), and leave all other future - /// price intervals untouched. If the `shift` parameter is set to `true`, Orb - /// will shift all subsequent price and adjustment intervals by the same amount - /// as the 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). + /// price intervals untouched. If the `shift` parameter is set to `true`, Orb will + /// shift all subsequent price and adjustment intervals by the same amount as the + /// 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). /// Task UpdateTrial( SubscriptionUpdateTrialParams parameters, @@ -950,7 +982,7 @@ public interface ISubscriptionServiceWithRawResponse ISubscriptionServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /subscriptions`, but is otherwise the + /// Returns a raw HTTP response for post /subscriptions, but is otherwise the /// same as . /// Task> Create( @@ -959,7 +991,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `put /subscriptions/{subscription_id}`, but is otherwise the + /// Returns a raw HTTP response for put /subscriptions/{subscription_id}, but is otherwise the /// same as . /// Task> Update( @@ -975,7 +1007,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `get /subscriptions`, but is otherwise the + /// Returns a raw HTTP response for get /subscriptions, but is otherwise the /// same as . /// Task> List( @@ -984,7 +1016,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `post /subscriptions/{subscription_id}/cancel`, but is otherwise the + /// Returns a raw HTTP response for post /subscriptions/{subscription_id}/cancel, but is otherwise the /// same as . /// Task> Cancel( @@ -1000,7 +1032,7 @@ Task> Cancel( ); /// - /// Returns a raw HTTP response for `get /subscriptions/{subscription_id}`, but is otherwise the + /// Returns a raw HTTP response for get /subscriptions/{subscription_id}, but is otherwise the /// same as . /// Task> Fetch( @@ -1016,7 +1048,7 @@ Task> Fetch( ); /// - /// Returns a raw HTTP response for `get /subscriptions/{subscription_id}/costs`, but is otherwise the + /// Returns a raw HTTP response for get /subscriptions/{subscription_id}/costs, but is otherwise the /// same as . /// Task> FetchCosts( @@ -1032,7 +1064,7 @@ Task> FetchCosts( ); /// - /// Returns a raw HTTP response for `get /subscriptions/{subscription_id}/schedule`, but is otherwise the + /// Returns a raw HTTP response for get /subscriptions/{subscription_id}/schedule, but is otherwise the /// same as . /// Task> FetchSchedule( @@ -1048,7 +1080,7 @@ Task> FetchSchedule( ); /// - /// Returns a raw HTTP response for `get /subscriptions/{subscription_id}/usage`, but is otherwise the + /// Returns a raw HTTP response for get /subscriptions/{subscription_id}/usage, but is otherwise the /// same as . /// Task> FetchUsage( @@ -1064,7 +1096,7 @@ Task> FetchUsage( ); /// - /// Returns a raw HTTP response for `post /subscriptions/{subscription_id}/price_intervals`, but is otherwise the + /// Returns a raw HTTP response for post /subscriptions/{subscription_id}/price_intervals, but is otherwise the /// same as . /// Task> PriceIntervals( @@ -1080,7 +1112,7 @@ Task> PriceIntervals( ); /// - /// Returns a raw HTTP response for `post /subscriptions/{subscription_id}/redeem_coupon`, but is otherwise the + /// Returns a raw HTTP response for post /subscriptions/{subscription_id}/redeem_coupon, but is otherwise the /// same as . /// Task> RedeemCoupon( @@ -1096,7 +1128,7 @@ Task> RedeemCoupon( ); /// - /// Returns a raw HTTP response for `post /subscriptions/{subscription_id}/schedule_plan_change`, but is otherwise the + /// Returns a raw HTTP response for post /subscriptions/{subscription_id}/schedule_plan_change, but is otherwise the /// same as . /// Task> SchedulePlanChange( @@ -1112,7 +1144,7 @@ Task> SchedulePlanChange( ); /// - /// Returns a raw HTTP response for `post /subscriptions/{subscription_id}/trigger_phase`, but is otherwise the + /// Returns a raw HTTP response for post /subscriptions/{subscription_id}/trigger_phase, but is otherwise the /// same as . /// Task> TriggerPhase( @@ -1128,7 +1160,7 @@ Task> TriggerPhase( ); /// - /// Returns a raw HTTP response for `post /subscriptions/{subscription_id}/unschedule_cancellation`, but is otherwise the + /// Returns a raw HTTP response for post /subscriptions/{subscription_id}/unschedule_cancellation, but is otherwise the /// same as . /// Task> UnscheduleCancellation( @@ -1144,7 +1176,7 @@ Task> UnscheduleCancellation( ); /// - /// Returns a raw HTTP response for `post /subscriptions/{subscription_id}/unschedule_fixed_fee_quantity_updates`, but is otherwise the + /// Returns a raw HTTP response for post /subscriptions/{subscription_id}/unschedule_fixed_fee_quantity_updates, but is otherwise the /// same as . /// Task> UnscheduleFixedFeeQuantityUpdates( @@ -1160,7 +1192,7 @@ Task> UnscheduleFixedFeeQuantityUpdates( ); /// - /// Returns a raw HTTP response for `post /subscriptions/{subscription_id}/unschedule_pending_plan_changes`, but is otherwise the + /// Returns a raw HTTP response for post /subscriptions/{subscription_id}/unschedule_pending_plan_changes, but is otherwise the /// same as . /// Task> UnschedulePendingPlanChanges( @@ -1176,7 +1208,7 @@ Task> UnschedulePendingPlanChanges( ); /// - /// Returns a raw HTTP response for `post /subscriptions/{subscription_id}/update_fixed_fee_quantity`, but is otherwise the + /// Returns a raw HTTP response for post /subscriptions/{subscription_id}/update_fixed_fee_quantity, but is otherwise the /// same as . /// Task> UpdateFixedFeeQuantity( @@ -1192,7 +1224,7 @@ Task> UpdateFixedFeeQuantity( ); /// - /// Returns a raw HTTP response for `post /subscriptions/{subscription_id}/update_trial`, but is otherwise the + /// Returns a raw HTTP response for post /subscriptions/{subscription_id}/update_trial, but is otherwise the /// same as . /// Task> UpdateTrial( diff --git a/src/Orb/Services/ITopLevelService.cs b/src/Orb/Services/ITopLevelService.cs index 24687cde6..1c91f396c 100644 --- a/src/Orb/Services/ITopLevelService.cs +++ b/src/Orb/Services/ITopLevelService.cs @@ -27,10 +27,10 @@ public interface ITopLevelService ITopLevelService WithOptions(Func modifier); /// - /// This endpoint allows you to test your connection to the Orb API and check - /// the validity of your API key, passed in the Authorization header. This is - /// particularly useful for checking that your environment is set up properly, - /// and is a great choice for connectors and integrations. + /// This endpoint allows you to test your connection to the Orb API and check the + /// validity of your API key, passed in the Authorization header. This is + /// particularly useful for checking that your environment is set up properly, and + /// is a great choice for connectors and integrations. /// /// This API does not have any side-effects or return any Orb resources. /// @@ -54,7 +54,7 @@ public interface ITopLevelServiceWithRawResponse ITopLevelServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `get /ping`, but is otherwise the + /// Returns a raw HTTP response for get /ping, but is otherwise the /// same as . /// Task> Ping( diff --git a/src/Orb/Services/InvoiceService.cs b/src/Orb/Services/InvoiceService.cs index 60d3b6c40..e57156793 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, @@ -212,12 +236,10 @@ public async Task Pay( /// public Task Pay( string invoiceID, - InvoicePayParams? parameters = null, + InvoicePayParams parameters, CancellationToken cancellationToken = default ) { - parameters ??= new(); - return this.Pay(parameters with { InvoiceID = invoiceID }, cancellationToken); } @@ -504,6 +526,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, @@ -609,12 +676,10 @@ public async Task> Pay( /// public Task> Pay( string invoiceID, - InvoicePayParams? parameters = null, + InvoicePayParams parameters, CancellationToken cancellationToken = default ) { - parameters ??= new(); - return this.Pay(parameters with { InvoiceID = invoiceID }, cancellationToken); } 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..7036f9436 --- /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..03fdc2d04 --- /dev/null +++ b/src/Orb/Services/Licenses/IUsageService.cs @@ -0,0 +1,95 @@ +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..01f6355d3 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 { @@ -28,8 +32,8 @@ public interface IExternalPlanIDService IExternalPlanIDService WithOptions(Func modifier); /// - /// This endpoint can be used to update the `external_plan_id`, and `metadata` - /// of an existing plan. + /// This endpoint can be used to update the `external_plan_id`, and `metadata` of an + /// existing plan. /// /// Other fields on a plan are currently immutable. /// @@ -48,18 +52,18 @@ Task Update( /// /// This endpoint is used to fetch [plan](/core-concepts##plan-and-price) details /// given an external_plan_id identifier. It returns information about the prices - /// included in the plan and their configuration, as well as the product that - /// the plan is attached to. + /// included in the plan and their configuration, as well as the product that the + /// plan is attached to. /// - /// If multiple plans are found to contain the specified external_plan_id, - /// the active plans will take priority over archived ones, and among those, - /// the endpoint will return the most recently created plan. + /// If multiple plans are found to contain the specified external_plan_id, the + /// active plans will take priority over archived ones, and among those, the + /// endpoint will return the most recently created plan. /// - /// ## Serialized prices Orb supports a few different pricing models out - /// of the box. Each of these models is serialized differently in a given [Price](/core-concepts#plan-and-price) - /// 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). " + /// ## Serialized prices Orb supports a few different pricing models out of + /// the box. Each of these models is serialized differently in a given + /// [Price](/core-concepts#plan-and-price) 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). " /// Task Fetch( ExternalPlanIDFetchParams parameters, @@ -88,7 +92,7 @@ public interface IExternalPlanIDServiceWithRawResponse IExternalPlanIDServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `put /plans/external_plan_id/{external_plan_id}`, but is otherwise the + /// Returns a raw HTTP response for put /plans/external_plan_id/{external_plan_id}, but is otherwise the /// same as . /// Task> Update( @@ -104,7 +108,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `get /plans/external_plan_id/{external_plan_id}`, but is otherwise the + /// Returns a raw HTTP response for get /plans/external_plan_id/{external_plan_id}, but is otherwise the /// same as . /// Task> Fetch( diff --git a/src/Orb/Services/Plans/IMigrationService.cs b/src/Orb/Services/Plans/IMigrationService.cs index 67a93560b..2c1ed932b 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 { @@ -42,10 +46,10 @@ Task Retrieve( ); /// - /// This endpoint returns a list of all migrations for a plan. The list of 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. + /// This endpoint returns a list of all migrations for a plan. The list of + /// 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. /// Task List( MigrationListParams parameters, @@ -89,7 +93,7 @@ public interface IMigrationServiceWithRawResponse IMigrationServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `get /plans/{plan_id}/migrations/{migration_id}`, but is otherwise the + /// Returns a raw HTTP response for get /plans/{plan_id}/migrations/{migration_id}, but is otherwise the /// same as . /// Task> Retrieve( @@ -105,7 +109,7 @@ Task> Retrieve( ); /// - /// Returns a raw HTTP response for `get /plans/{plan_id}/migrations`, but is otherwise the + /// Returns a raw HTTP response for get /plans/{plan_id}/migrations, but is otherwise the /// same as . /// Task> List( @@ -121,7 +125,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `post /plans/{plan_id}/migrations/{migration_id}/cancel`, but is otherwise the + /// Returns a raw HTTP response for post /plans/{plan_id}/migrations/{migration_id}/cancel, but is otherwise the /// same as . /// Task> Cancel( diff --git a/src/Orb/Services/Prices/IExternalPriceIDService.cs b/src/Orb/Services/Prices/IExternalPriceIDService.cs index 0307b3e80..0da9f3be0 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 { @@ -28,9 +38,9 @@ public interface IExternalPriceIDService IExternalPriceIDService WithOptions(Func modifier); /// - /// 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. + /// 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. /// Task Update( ExternalPriceIDUpdateParams parameters, @@ -45,9 +55,9 @@ Task Update( ); /// - /// 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. + /// 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. /// Task Fetch( ExternalPriceIDFetchParams parameters, @@ -76,7 +86,7 @@ public interface IExternalPriceIDServiceWithRawResponse IExternalPriceIDServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `put /prices/external_price_id/{external_price_id}`, but is otherwise the + /// Returns a raw HTTP response for put /prices/external_price_id/{external_price_id}, but is otherwise the /// same as . /// Task> Update( @@ -92,7 +102,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `get /prices/external_price_id/{external_price_id}`, but is otherwise the + /// Returns a raw HTTP response for get /prices/external_price_id/{external_price_id}, but is otherwise the /// same as . /// Task> Fetch( diff --git a/src/Orb/Shims.cs b/src/Orb/Shims.cs index afd5582f1..c93321fb8 100644 --- a/src/Orb/Shims.cs +++ b/src/Orb/Shims.cs @@ -15,27 +15,36 @@ namespace System.Runtime.CompilerServices AllowMultiple = false, Inherited = false )] - internal sealed class RequiredMemberAttribute : Attribute; + internal sealed class RequiredMemberAttribute : Attribute { } [AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)] - internal sealed class CompilerFeatureRequiredAttribute(string feature) : Attribute; + internal sealed class CompilerFeatureRequiredAttribute : Attribute + { + public CompilerFeatureRequiredAttribute(string feature) { } + } // Allow `init` to compile when targeting .NET Standard 2.0. - internal static class IsExternalInit; + internal static class IsExternalInit { } } namespace System.Diagnostics.CodeAnalysis { // Allow `[SetsRequiredMembers]` to compile when targeting .NET Standard 2.0. [AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)] - internal sealed class SetsRequiredMembersAttribute : Attribute; + internal sealed class SetsRequiredMembersAttribute : Attribute { } // Allow `[MaybeNullWhen(...)]` to compile when targeting .NET Standard 2.0. [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] - internal sealed class MaybeNullWhenAttribute(bool returnValue) : Attribute; + internal sealed class MaybeNullWhenAttribute : Attribute + { + public MaybeNullWhenAttribute(bool returnValue) { } + } // Allow `[NotNullWhen(...)]` to compile when targeting .NET Standard 2.0. [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] - internal sealed class NotNullWhenAttribute(bool returnValue) : Attribute; + internal sealed class NotNullWhenAttribute : Attribute + { + public NotNullWhenAttribute(bool returnValue) { } + } } #endif